forked from askeing/B2G-flash-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_resolution.sh
executable file
·115 lines (102 loc) · 3.15 KB
/
check_resolution.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
#==========================================================================
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#==========================================================================
# Description:
# This script was written for checking using the correct resolution icons.
#
# Author: Al Tsai[:atsai] [email protected]
# History:
# 2013/07/22 Al: v1.0 First release (only for helix).
#==========================================================================
####################
# Parameter Flags
####################
Branch="helix"
Resolution="@1.5x"
Gaia_Path=
Base_File=
####################
# Functions
####################
function helper(){
echo "[checkResolution.sh] Coming soon..."
}
####################
# Executions
####################
## distinguish platform
case `uname` in
"Linux")
## add getopt argument parsing
TEMP=`getopt -o b::p::r:: --long branch::,gaia_path::,resolution -n 'error occured' -- "$@"`
if [ $? != 0 ]; then echo "Terminating..." >&2; exit 1; fi
eval set -- "$TEMP";;
"Darwin");;
esac
while true
do
case "$1" in
-b|--branch) Branch=$2; shift 2;;
-p|--gaia_path) Gaia_Path=$2; shift 2;;
-r|--resolution)
case "$2" in
"1.5") Resolution="@1.5x"; shift 2;;
"2.0"|"2") Resolution="@2x"; shift 2;;
esac;;
-h|--help) helper; exit 0;;
--) shift;break;;
"") shift;break;;
*) echo error occured; exit 1;;
esac
done
rm -rf dir > /dev/null &> /dev/null
rm size.txt > /dev/null &> /dev/null
rm sizeDiff.txt > /dev/null &> /dev/null
mkdir dir > /dev/null &> /dev/null
echo "Pull data from device"
adb wait-for-device
adb pull /data/local/webapps/ dir/ > /dev/null &> /dev/null
cd dir
for f in $(ls */application.zip)
do
path=${f%.*}
unzip $f style/images/* -d $path > /dev/null 2>&1
for images in $(ls $path/style/images/*.png 2> /dev/null)
do
echo $images >> ../size.txt
ls -al $images | awk '{print $5}' >> ../size.txt
done
done
if [ -d "${Gaia_Path}" ]; then
echo "Use path: "${Gaia_Path}
for images in $(ls $Gaia_Path/apps/*/style/images/*$Resolution.png 2> /dev/null)
do
suffix="${images##*/apps/}"
prefix="${suffix%/style*}"
fn=$(basename $images)
echo $prefix.gaiamobile.org/application/style/images/${fn%%$Resolution*}.png >> ../gaiaPngSize.txt
ls -al $images | awk '{print $5}' >> ../gaiaPngSize.txt
done
Base_File="../gaiaPngSize.txt"
else
echo "Use data on altsai respository for comparison"
git clone http://github.com/altsai/checkResolution.git
cd checkResolution
git checkout $Branch 2>&1
cd ..
Base_File="checkResolution/size.txt"
fi
echo "diff -u $Base_File ../size.txt > sizeDiff.txt"
diff -u $Base_File ../size.txt > sizeDiff.txt
fileSize=$(ls -al sizeDiff.txt | awk '{print $5}')
if [ $fileSize == "0" ]; then
echo "TEST PASS!"
else
cp sizeDiff.txt ../
echo "output Diff to sizeDiff.txt"
fi
cd ..
rm -rf dir