summaryrefslogtreecommitdiffstats
path: root/tests/systemtests/sys_versit/sys_versit.qtt
blob: 6d832ba0167fb29021e6546ac9892b8991fe8cfc (plain)
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

//TESTED_COMPONENT=src/versit

// helper function re :contact actions may be in a separate "Contacts menu"
function contactsMenuItem(menuText)
{
    var menuEntries = getValue(menuBar()).toString().split("\n");
    var index = 0;
    var separateMenu = false; // optimize number of calls to indexOf

    for (index = 0; index < menuEntries.length; index++){
        if (!separateMenu && menuEntries[index].indexOf("&Contacts") >= 0){
            separateMenu = true;
            menuText = "&Contacts/" + menuText;
        }
        if (menuEntries[index] == menuText)
            return menuText;
    }

    return undefined;

}

function importContactsMenu() {
    return contactsMenuItem("&Import contacts...");
}

function exportVCardContactsMenu() {
    return contactsMenuItem("Ex&port contacts...");
}

var checkImportedVCardContactData = new Array(
   ["John Smith", "+123456", "John.Smith@SmithsComputerServices.com", "1/21 Anywhere St", "BAT"],
   ["Bill Smith", "+9876", "Bill.Smith@SmithsComputerServices.com", "2/21 Anywhere St", "BAT"]
);

testcase = {

    importVCardContacts_data : {
        vCard1 : ["testdata/testimport1.vcf"]
    },

    importVCardContacts: function(vCardFile)
    {
        // Test meta data
        testTitle = "Versit - Import vCard contacts";
        testBinary = "samplephonebook";
        testSource = "$MOBILITYDIR/example/samplephonebook";
        testGoal = "Verify that vCard contacts can be imported";
        testPreconditions = "There is an testimport1.vcf onto a location on the target";
        testGroups = "BAT_MOBILITY";
        testRequirements = ""
            
        var promptText = "| *Name* | *Phone Number* | *Email* | *Address* | *Avatar* |\n";
        for (var contactIndex=0; contactIndex < checkImportedVCardContactData.length;contactIndex++){
            for (var contactDataIndex=0; contactDataIndex < checkImportedVCardContactData[0].length; contactDataIndex++){
                promptText += "|" + checkImportedVCardContactData[contactIndex][contactDataIndex];
            }
            promptText += "|\n";
            }

        // Test Steps
        if (!runAsManualTest()){
            startApplication("samplephonebook");
            var menuItem = importContactsMenu();
            if (menuItem == undefined)
                skip("Versit support not enabled", SkipAll);
            select(menuItem, menuBar());
            enter(vCardFile, "File name:");
            // need to accept entry due to autocompletion
            keyClick(Qt.Key_Enter);
            // verify the contacts
            for (var contactIndex=0; contactIndex < checkImportedVCardContactData.length;contactIndex++){
                var contactList = findWidget( { className: "QListWidget" } );
                select(checkImportedVCardContactData[contactIndex][0], contactList[0]);
                select("&Edit");
                compare(getText("Name"), checkImportedVCardContactData[contactIndex][0]);
                compare(getText("Phone"), checkImportedVCardContactData[contactIndex][1]);
                compare(getText("Email"), checkImportedVCardContactData[contactIndex][2]);
                compare(getText("Address"), checkImportedVCardContactData[contactIndex][3]);
                prompt("Verify that the Avatar looks like the word *BAT*");
                select("Cancel");
            }
        } else {
            prompt(twiki("---+++ " + testTitle + "<br><br>
                *Goal:* " + testGoal + "<br>
                *Pre-Requisites:* " + testPreconditions + "<br>
                *Tested Binary:* " + testBinary + "<br>
                *Requirements:* " + testRequirements + "<br>
            
                | *Step* | *Verification* |
                | Launch " + testBinary + " | Test application started successfully |
                | Select the Import Contacts... menu entry | |
                | Enter the vCard file name of : *" + vCardFile + "* | |
                | Accept the value for vCard file (close file selection dialog) | Verify that no errors are present on screen |
                |||
                Verify the imported contacts :\n " + promptText + "                
            "));
        }
    },

    exportVCardContacts_data : {
        NameSet1 : ["contacts.vcf", "FN:John Smith", "FN:Bill Smith"]
    },

    /* Requirement : Verify contact export*/
    /* If versit suport is present test it */
    
    exportVCardContacts: function(vCardFile, name1, name2)
    {
        // Test meta data
        testTitle = "Versit - Export vCard contacts";
        testBinary = "samplephonebook";
        testSource = "$MOBILITYDIR/example/samplephonebook";
        testGoal = "Verify that vCard contacts can be exported";
        testPreconditions = "None";
        testGroups = " ";
        testRequirements = ""

        if (!runAsManualTest()){
            startApplication("samplephonebook");
            var menuItem = exportVCardContactsMenu();
            if (menuItem == undefined)
                skip("Versit support not enabled", SkipAll);

            select(menuItem, menuBar());

            enter(vCardFile, "File name:");
            // need to accept entry due to autocompletion
            keyClick(Qt.Key_Enter);
            var contactVCFData = getData(vCardFile);
            if (!(contactVCFData.indexOf(name1)
                && contactVCFData.indexOf(name2))) {
                print(".vcf contains:" + contactVCFData);
                deletePath(contactsVCFFile);
                fail("Did not find in .vcf:" + name1 + "," + name2);
            }
            deletePath(vCardFile);
        }else{
            prompt(twiki("---+++ " + testTitle + "<br><br>
                *Goal:* " + testGoal + "<br>
                *Pre-Requisites:* " + testPreconditions + "<br>
                *Tested Binary:* " + testBinary + "<br>
                *Requirements:* " + testRequirements + "<br>
            
                | *Step* | *Verification* |
                | Launch " + testBinary + " | Test application started successfully |
                | Select the Export Contacts... menu entry | |
                | Enter name of contacts vCard as *" + vCardFile + "* | Verify that *" + vCardFile + "* contains *" + name1 + "* and *" + name2 + "* |
            "));
        }
    }
}