Fix the issues of TC
[platform/core/appfw/shortcut.git] / test_db_builder.sh
1 #!/bin/sh
2 #/*
3 # * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
4 # *
5 # * Licensed under the Apache License, Version 2.0 (the "License");
6 # * you may not use this file except in compliance with the License.
7 # * You may obtain a copy of the License at
8 # *
9 # * http://www.apache.org/licenses/LICENSE-2.0
10 # *
11 # * Unless required by applicable law or agreed to in writing, software
12 # * distributed under the License is distributed on an "AS IS" BASIS,
13 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # * See the License for the specific language governing permissions and
15 # * limitations under the License.
16 # *
17 #*/
18
19 DBFILE="/opt/dbspace/.shortcut_service.db"
20
21 APPID=(
22 "com.samsung.facebook"
23 "com.samsung.facebook"
24 "com.samsung.facebook"
25 "com.samsung.facebook"
26 "com.samsung.facebook"
27 )
28
29 ICON=(
30 ""
31 ""
32 ""
33 ""
34 ""
35 )
36
37 NAME=(
38 "Friend's wall"
39 "Groups"
40 "Update status"
41 "Like by me"
42 "My wall"
43 )
44
45 KEY=(
46 "livebox_shortcut_type"
47 "livebox_shortcut_type"
48 "livebox_shortcut_type"
49 "livebox_shortcut_type"
50 "livebox_shortcut_type"
51 )
52
53 VALUE=(
54 "shortcut_friends"
55 "shortcut_groups"
56 "shortcut_post"
57 "shortcut_like"
58 "shortcut_me"
59 )
60
61 CNT=0
62 ERR=0
63 MAX=5
64
65 sqlite3 $DBFILE "CREATE TABLE shortcut_service (id INTEGER PRIMARY KEY AUTOINCREMENT, appid TEXT, icon TEXT, name TEXT, extra_key TEXT, extra_data TEXT)"
66 sqlite3 $DBFILE "CREATE TABLE shortcut_name (id INTEGER, lang TEXT, name TEXT)"
67 while [ $CNT -lt $MAX ]
68 do
69         echo "Insert a new record ('${APPID[$CNT]}', '${ICON[$CNT]}', '${NAME[$CNT]}', \"${KEY[$CNT]}\", \"${VALUE[$CNT]}\")"
70         sqlite3 $DBFILE "INSERT INTO shortcut_service (appid, icon, name, extra_key, extra_data) VALUES ('${APPID[$CNT]}', '${ICON[$CNT]}', \"${NAME[$CNT]}\", \"${KEY[$CNT]}\", \"${VALUE[$CNT]}\")" 2>/dev/null
71         if [ $? -ne 0 ]; then
72                 let ERR=$ERR+1
73         fi
74         ID=`sqlite3 $DBFILE "SELECT id FROM shortcut_service WHERE appid = \"${APPID[$CNT]}\" AND extra_key = \"${KEY[$CNT]}\" AND extra_data = \"${VALUE[$CNT]}\""`
75         echo "Insert a name: \"${NAME[$CNT]}\""
76         sqlite3 $DBFILE "INSERT INTO shortcut_name (id, lang, name) VALUES ('$ID', 'en-us', \"${NAME[CNT]}\")"
77         let CNT=$CNT+1
78 done
79
80 echo "Error/Total: $ERR/$CNT"