/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of QtUiTest. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions ** contained in the Technology Preview License Agreement accompanying ** this package. ** ** 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, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. ** ** ** ** ** ** ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ testcase = { runAsManualTest: function() { if (!runAsManualTest()) skip( "This test only makes sense when executed in -force-manual mode" ); manualTest( "Do something" ); startApplication("foobar"); prompt( "This should all nicely fold into one big prompt" ); prompt( "Line 1\nLine 2\nLine 3" ); verify( isVisible( "blah" ) ); verify( isVisible( activeWindow() ) ); compare( getText(focusWidget()), "this text" ); compare( "this text", getText(focusWidget()) ); compare( getSelectedText(tabBar()), getText(focusWidget()) ); select( "foo", tabBar() ); compare( getSelectedText(tabBar()), "First Tab" ); compare( getSelectedValue("Name"), "a reference value" ); compare( getValue("Address"), "Elysium road" ); compare( "Elysium road", getValue("Address") ); compare( getList( "Friends"), getList( "Other Friends") ); mouseClick( getCenter( "foo", "bar" ) ); var l = getLabels( "app" ); verify(l.contains("Name"), "Verify that labels for 'app' contain 'Name'"); setClipboardText( l ); compare( getClipboardText(), "foobar" ); compare( currentTitle(), "Contacts" ); compare( getWindowTitles(), "A\nB\nC" ); activateWindow( "mainwindow" ); verify( getenv( "PATH" ).contains( "/home/user/foobar" ) ); verify( checkOS( "linux" ) ); verifyImage( "task_completed", "", "Verify that the current task is shown with a green tick indicating completion" ); verify( compareImage( "expected", "actual" )); verify( getData("srcFile") == "blah" ); verify( getImageSize( "srcFile" ) == "12345" ); getFile("/tmp/foo.conf", "$HOME/Settings/foo.conf" ); putFile("testdata/my_settings.conf", "$HOME/Settings/foo.conf"); putFile("testdata/my_file", "$HOME/my_file", 12 ); //QFile.WriteOwner | QFile.ReadOwner | QFile.ReadOther); }, runAutoTest: function() { if (runAsManualTest()) skip( "This test only makes sense when NOT executed in -force-manual mode" ); startApplication("testapp1"); manualTest( "step 1"); manualTest( "step 2"); manualTest( "step 3"); compare(currentTitle(), "testapp1"); manualTest( "step4" ); manualTest( "step5" ); manualTest( "step6" ); }, activate_tabBar: function() { startApplication("testapp1"); select( "First Tab", tabBar() ); compare( getSelectedText(tabBar()), "First Tab" ); select( "Cow Tab", tabBar() ); compare( getSelectedText(tabBar()), "Cow Tab" ); select( "First Tab", tabBar() ); compare( getSelectedText(tabBar()), "First Tab" ); select( "Awesome Tab", tabBar() ); compare( getSelectedText(tabBar()), "Awesome Tab" ); }, enter_single_data: { numeric: "0", asterisk: "*", percent: "%", question: "?", comma: ",", lower1: "a", upper: "B", lower2: "z" }, enter_single: function(character) { startApplication("testapp1"); select( "First Tab", tabBar() ); enter(character, "Status"); compare(getText("Status"), character); }, enter_text: function(text) { startApplication("testapp1"); select( "First Tab", tabBar() ); enter(text, "LineEdit1"); compare( getText("Status"), "LineEdit1 text changed" ); compare( getText("LineEdit1"), text ); enter("clear", "LineEdit2"); compare( getText("Status"), "LineEdit2 text changed" ); compare( getText("LineEdit2"), "clear" ); if (mousePreferred()) { mouseClick("LineEdit1"); keyClick(Qt.Key_Home); mouseClick("LineEdit2"); } enter("overwrite", "LineEdit1"); compare( getText("LineEdit1"), "overwrite" ); }, enter_text_data: { mixed_case: [ "MiXeD CASe" ], punctuation: [ "!@#$%^&*()-=_+[]{}\|;:',./<>?`~" ], allsorts: [ "$100! How Much?" ], with_numbers: [ "1 2 3SD770 4 25 312" ], in_dict: [ "hello kitty" ], not_in_dict: [ "jtnerlnjas mtrnen" ], long_str: [ "this is a really long string to test we can overwrite properly" ], // Test for bug: "Jimmy" sometimes gives "Jinny" in predictive keyboard. jimmy: [ "Jimmy jimmy" ] }, enter_QTextEdit: function(text) { startApplication("testapp3"); select("Text", tabBar()); enter(text, "Text"); compare( getText("Text"), text ); enter("overwrite", "Text"); compare( getText("Text"), "overwrite" ); }, enter_QTextEdit_data: { single_line: [ "This is a single line" ], //multi_lines: [ "This is\nmultiple lines of\n\ntext" ] alotta_text: [ "This is a lot of text to ensure we get a scroll bar happening yes this is a lot of text to ensure we get a scroll bar happening yes" ] }, enter_QTimeEdit: function(time, shouldPass) { startApplication("testapp1"); select("Awesome Tab", tabBar()); if (!shouldPass) expectFail("Bad time given"); enter(time, "Time"); compare( getValue("Time"), time ); }, enter_QTimeEdit_data: { simple1: [ new QTime(16, 55, 00), true ], simple2: [ new QTime(14, 10, 38), true ], sdigit1: [ new QTime(1, 33, 10), true ], sdigit2: [ new QTime(19, 7, 11), true ], sdigit3: [ new QTime(22, 21, 1), true ], bad1: [ new QTime(25, 21, 1), false ], bad2: [ new QTime(22, 88, 1), false ], bad3: [ new QTime(21, 21, -1), false ] }, // enter() with QDateEdit fields. enter_QDateEdit: function(date) { startApplication("testapp1"); select("Awesome Tab", tabBar()); enter(date, "Date"); compare( getValue("Date"), date ); }, enter_QDateEdit_data: { simple1: [ new Date(2000, 6, 15) ], december: [ new Date(2000, 12, 15) ], end_of_month: [ new Date(2002, 6, 30) ], simple2: [ new Date(2004, 10, 11) ] }, // Explicit mouse clicks on widgets mouseClick: function() { startApplication("testapp1"); select( "Cow Tab", tabBar() ); compare( getSelectedText(tabBar()), "Cow Tab" ); mouseClick("CowButton1"); compare( getText("CowStatus"), "CowButton1 clicked" ); mouseClick("CowButton2"); compare( getText("CowStatus"), "CowButton2 clicked" ); mouseClick("CowButton16"); compare( getText("CowStatus"), "CowButton16 clicked" ); mouseClick("CowButton0"); compare( getText("CowStatus"), "CowButton0 clicked" ); }, activate_button: function() { startApplication("testapp1"); select("First Tab", tabBar()); compare( getSelectedText(tabBar()), "First Tab" ); select("Button1"); compare( getText("Status"), "Button1 clicked" ); select("Button2"); compare( getText("Status"), "Button2 clicked" ); }, activate_combobox: function() { startApplication("testapp1"); select( "Cow Tab", tabBar() ); select( "Woof", "Cow Goes?" ); compare( getText("CowStatus"), "Cow Goes? changed" ); compare( getSelectedText("Cow Goes?"), "Woof" ); // To clear 'Status' select( "CowButton0" ); compare( getText("CowStatus"), "CowButton0 clicked" ); select( "Moo", "Cow Goes?" ); compare( getText("CowStatus"), "Cow Goes? changed" ); compare( getSelectedText("Cow Goes?"), "Moo" ); }, activate_editable_combobox: function() { startApplication("testapp1"); select( "First Tab", tabBar() ); select( "Yellow", "Colour" ); compare( getText("Status"), "Colour changed" ); compare( getSelectedText("Colour"), "Yellow" ); // To clear 'Status' select("Button1"); compare( getText("Status"), "Button1 clicked" ); select( "Blue", "Colour" ); compare( getText("Status"), "Colour changed" ); compare( getSelectedText("Colour"), "Blue" ); }, scroll_scrollarea_vertical: function() { startApplication("testapp1"); select( "Cow Tab", tabBar() ); select( "CowButton0" ); compare( getText("CowStatus"), "CowButton0 clicked" ); // Scroll down to the bottom select( "CowButton15" ); compare( getText("CowStatus"), "CowButton15 clicked" ); // Scroll up to the top select( "CowButton0" ); compare( getText("CowStatus"), "CowButton0 clicked" ); }, scroll_combobox: function() { startApplication("testapp1"); select( "Cow Tab", tabBar() ); select( "Woof", "Cow Goes?" ); compare( getText("CowStatus"), "Cow Goes? changed" ); compare( getSelectedText("Cow Goes?"), "Woof" ); // This item is the last one in the combobox select( "Choo choo!", "Cow Goes?" ); compare( getText("CowStatus"), "Cow Goes? changed" ); compare( getSelectedText("Cow Goes?"), "Choo choo!" ); }, setChecked_checkbox: function() { startApplication("testapp1"); select( "Awesome Tab", tabBar() ); select( "Clear" ); compare( getText("Status"), "'Clear' clicked" ); setChecked( true, "Checkbox" ); compare( getText("Status"), "'Checkbox' clicked" ); verify( isChecked("Checkbox") ); select( "Clear" ); compare( getText("Status"), "'Clear' clicked" ); setChecked( false, "Checkbox" ); compare( getText("Status"), "'Checkbox' clicked" ); verify( !isChecked("Checkbox") ); select( "Clear" ); compare( getText("Status"), "'Clear' clicked" ); setChecked( true, "Checkbox" ); compare( getText("Status"), "'Checkbox' clicked" ); verify( isChecked("Checkbox") ); }, select_groupbox_subitem: function() { startApplication("testapp2"); setChecked(true, "Checkable"); select("Checkable/Groupie"); compare("'Groupie' clicked", getText("Status")); setChecked(false, "Checkable"); expectFail("Can't select disabled button"); select("Checkable/Groupie"); }, select_from_popup: function() { startApplication("testapp2"); select( "Tab Two", tabBar() ); select("Popup"); select("&No"); compare("No", getText("Popup response")); select("Popup"); select("&Yes"); compare("Yes", getText("Popup response")); }, enter_invisible: function() { startApplication("testapp2"); select( "Tab Two", tabBar() ); setChecked(true, "Checkbox"); enter("hello world", "Silly 1"); setChecked(false, "Checkbox"); expectFail("Can't enter text into non-visible widget"); enter("hello again world", "Silly 2"); }, select_menu: function() { startApplication("testapp2"); select( "Tab Free", tabBar() ); select("Menu Item #3", "Menu"); compare("Menu Item #3", getText("Menu")); } }