~vasudevank2/ubuntu-autopilot-tests/nautilus_autopilot_1.3

« back to all changes in this revision

Viewing changes to ubuntu_autopilot_tests/fileroller/test_fileroller.py

  • Committer: Carla Sella
  • Date: 2013-03-25 20:17:09 UTC
  • Revision ID: carla.sella@gmail.com-20130325201709-knf2o39xulo5grq2
needs to be reviewed in adding files to archive 

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
#Register File-roller as an application so we can call it
12
12
AutopilotTestCase.register_known_application("Archive Manager", "file-roller.desktop", "file-roller")
13
 
 
14
13
#http://packages.qa.ubuntu.com/qatracker/testcases/1418/info
15
14
class GtkToolbarTests(AutopilotTestCase, GtkIntrospectionTestMixin):
16
15
 
27
26
    def test_archive_and_extract(self):
28
27
        #Test-case name: fileroller/flr-001
29
28
        # This test will check that File Roller can archive and extract files 
30
 
 
31
29
         
32
30
        #Click 'New' button from the toolbar
33
31
        #FrWindow, GtkGrid, GtkToolbar, GtkToolButton
34
32
        self.assertThat(lambda: self.app.select_single('GtkToolButton', name='New'), Eventually(NotEquals(None)))
35
33
        btn = self.app.select_single('GtkToolButton', name='New')
36
 
        #does it exist?  
37
 
        self.assertThat(btn, NotEquals(None))
38
34
        #let's click it
39
35
        self.mouse.move_to_object(btn)
40
36
        self.mouse.click()
50
46
        
51
47
        # select 'Tar compressed with gzip' from available formats combobox
52
48
        #TODO
53
 
        #FrNewArchiveDialog, Gtkbox, GtkHBox, GtkVbox, GtkTable, GtkHbox, GtkEntry, GtkComboBoxText
 
49
        #FrNewArchiveDialog, Gtkbox, GtkHBox, GtkVbox, GtkTable, GtkHbox, GtkComboBoxText
54
50
        # active = 9
55
 
    
 
51
     
 
52
        #TODO
 
53
        #Verify that .tar.gz file format is selected
 
54
        #selectWindow = self.app.select_single('GtkComboBoxText', active='9')
 
55
        #self.assertThat(lambda: self.app.select_single('GtkComboBoxText').active, Eventually(Contains(9)))
 
56
        #does not work as it's not an unique identifier
56
57
        
57
58
        #click 'Create' button
58
59
        #FrNewArchiveDialog,   GtkBox, GtkButtonBox, GtkButton
59
60
        #label: create-archive  (the name property is empty :(  )
60
61
        self.assertThat(lambda: self.app.select_single('GtkButton', label='create-archive'), Eventually(NotEquals(None)))
61
62
        createButton = self.app.select_single('GtkButton', label='create-archive')
62
 
        #does it exist?
63
 
        self.assertThat(createButton, NotEquals(None))
64
63
        #let's click it
65
64
        self.mouse.move_to_object(createButton)
66
65
        self.mouse.click()
67
66
        #delay to wait
68
 
        sleep(5)
 
67
        sleep(2)
69
68
                
70
69
        #Click 'Add files to archive' button from toolbar
71
 
        #FrWindow, GtkGrid, GtkToolButton, GtkButton
72
 
        #tooltip_text: 'Add files to archive'  (the name property is empty :(  )
 
70
        #FrWindow, GtkGrid, GtkToolButton
 
71
        #name: 'Add_Toolbar'  
73
72
        self.assertThat(lambda: self.app.select_single('GtkToolButton', name='Add_Toolbar'), Eventually(NotEquals(None)))
74
73
        addFilesButton = self.app.select_single('GtkToolButton', name='Add_Toolbar')
75
 
        #does it exist?
76
 
        self.assertThat(addFilesButton, NotEquals(None))
77
74
        #let's click it
78
75
        self.mouse.move_to_object(addFilesButton)
79
76
        self.mouse.click()
80
 
       #delay to wait
81
 
        sleep(1)
 
77
        #delay to wait
 
78
        sleep(2)
82
79
 
83
80
        #Verify that the Add files dialog window has opened
84
81
        #FrFileSelectorDialog
85
82
        selectWindow = self.app.select_single('FrFileSelectorDialog')
86
83
        self.assertThat(lambda: self.app.select_single('FrFileSelectorDialog').title, Eventually(Contains("Add Files"))) 
87
 
                
 
84
  
 
85
        #
 
86
        # DOES NOT WORK !!!!   ********************************************
 
87
        #
88
88
        #Select any files and/or folders to be added to the archive, click 'Add' button
89
89
        self.keyboard.press_and_release("Alt+l")
90
 
        self.keyboard.type("/usr/share/doc/gnome-terminal")
 
90
        self.keyboard.type("/usr/share/example-content/Ubuntu_Free_Culture_Showcase/*")
 
91
        #
 
92
        # DOES NOT WORK !!!!    ********************************************
 
93
        #
91
94
 
92
 
        #FrFileSelectorDialog, GtkBox, GtkButtonBox, GtkButton
93
 
        #label: add-folder-to-archive
94
 
        self.assertThat(lambda: self.app.select_single('GtkButton', label='add-folder-to-archive'), Eventually(NotEquals(None)))
95
 
        btn = self.app.select_single('GtkButton', label='add-folder-to-archive')
96
 
        
97
 
        #does it exist?
98
 
        self.assertThat(btn, NotEquals(None))
 
95
        #FrFileSelectorDialog, GtkBox, GtkButtonBox, GtkButton, GtkAlignment, GtkBox, GtkLable
 
96
        #label: _Add
 
97
        self.assertThat(lambda: self.app.select_single('GtkLabel', label='_Add'), Eventually(NotEquals(None)))
 
98
        addFolerButton = self.app.select_single('GtkLabel', label='_Add')
99
99
        #let's click it
100
 
        self.mouse.move_to_object(btn)
 
100
        self.mouse.move_to_object(addFolerButton)
101
101
        self.mouse.click()
102
102
        
103
 
        #Close file-roller
104
 
        
105
 
        #open nautilus and navigate to the folder where the archive has been created
106
 
        
 
103
        #Close the archive and file-roller
 
104
        self.keyboard.press_and_release("Alt+a")
 
105
        self.keyboard.type("c")
107
106
        
108
107
        #Open the archive using file-roller
 
108
        super(GtkToolbarTests, self).setUp()
 
109
        self.app = self.launch_test_application('file-roller')
 
110
        #FrWindow, GtkGrid, GtkToolbar, GtkMenuToolButton, GTkBox, GtkButton, GtkBox, GtkImage
 
111
        #stock: gtk-open
 
112
        self.assertThat(lambda: self.app.select_single('GtkImage', stock='gtk-open'), Eventually(NotEquals(None)))
 
113
        openRecentButton = self.app.select_single('GtkImage', stock='gtk-open')
 
114
        #let's click it
 
115
        self.mouse.move_to_object(openRecentButton)
 
116
        self.mouse.click()
 
117
        #delay to wait
 
118
        sleep(2)
 
119
        #GtkFileChooserDialog, GtkBox, GtkFileChooserWidget, GtkFileChooserDefault, GtkBox, GtkBox, GtkBox, GtkToggleButton, GtkAligmment, GtkBox, GtkImage
 
120
        #stock: gtk-edit
 
121
        self.assertThat(lambda: self.app.select_single('GtkImage', stock='gtk-edit'), Eventually(NotEquals(None)))
 
122
        fileNameToggleButton = self.app.select_single('GtkImage', stock='gtk-edit')
 
123
        #let's click it only if it is not already active
 
124
        fileAttributeToggleBut = self.app.select_single('GtkToggleButton', tooltip_markup='Type a file name')
 
125
        if  self.assertProperty(fileAttributeToggleBut, active = False):
 
126
            self.mouse.move_to_object(fileNameToggleButton)
 
127
            self.mouse.click()
 
128
           #delay to wait
 
129
            sleep(2)
 
130
        else:
 
131
            self.keyboard.press_and_release("Alt+1")
 
132
            
 
133
        self.keyboard.type(tempFile)
109
134
        
 
135
        #GtkFileChooserDialog, GtkBox, GtkButtonBox, GtkButton, GtkAligmment, GtkBox, GtkImage
 
136
        #stock: gtk-open
 
137
        self.assertThat(lambda: self.app.select_single('GtkImage', stock='gtk-open'), Eventually(NotEquals(None)))
 
138
        openFileButton = self.app.select_single('GtkImage', stock='gtk-open')
 
139
        #let's click it
 
140
        self.mouse.move_to_object(openFileButton)
 
141
        self.mouse.click()
 
142
        #delay to wait
 
143
        sleep(2)
110
144
        
111
145
        # Click 'Extract' button from toolbar
 
146
        #FrWindow, Gtkgrid, GtkToolBar, GtkMenuToolButton, 
 
147
        #name: Extract_ToolBar
 
148
        self.assertThat(lambda: self.app.select_single('GtkMenuToolButton', name='Extract_ToolBar'), Eventually(NotEquals(None)))
 
149
        extractFileButton = self.app.select_single('GtkMenuToolButton', name='Extract_ToolBar')
 
150
        #let's click it
 
151
        self.mouse.move_to_object(extractFileButton)
 
152
        self.mouse.click()
 
153
        #delay to wait
 
154
        sleep(2)
112
155
        
113
156
        #Select any folder to extract files to, click 'Extract' button
114
 
        
115
 
                
 
157
        self.keyboard.press_and_release("Alt+l")
 
158
        self.keyboard.type(tempfile.gettempdir)  
 
159
        #GtkFileChooserDialog, GtkBox, GtkButtonBox, GtkButton, GtkAligmment, GtkBox, GtkImage
 
160
        #stock: extract-archive
 
161
        self.assertThat(lambda: self.app.select_single('GtkImage', stock='extract-archive'), Eventually(NotEquals(None)))
 
162
        extractFileButton = self.app.select_single('GtkImage', stock='extract-archive')
 
163
        #let's click it
 
164
        self.mouse.move_to_object(extractFileButton)
 
165
        self.mouse.click()
 
166
        #delay to wait
 
167
        sleep(2)        
116
168
        
117
169
        #Wait until extracting process is complete
118
 
        
119
170
        #'Extraction completed successfully' label appears
120
 
        
 
171
        #GtkDialog, GtkBox, GtkHBox, GtkBox, GtkLabel
 
172
        #label: <span weight="bold" size="larger">Extraction completed successfully</span>
 
173
        selectWindow = self.app.select_single('GtkDialog')
 
174
        self.assertThat(lambda: self.app.select_single('GtkLabel').label, Eventually(Contains("<span weight=""bold"" size=""larger"">Extraction completed successfully</span>"))) 
 
175
          
 
176
        #TODO
121
177
        #Open Nautilus and navigate to the selected extract folder
122
178
        #Are the files and folders from archive extracted correctly in the selected folder?
123
179
        
124
 
        #Delete tempFile
125
 
        #self.deleteFile(tempFile)
126
 
        
 
180
        #Delete the temp file we created
 
181
        #Added sleep so file does not get removed too soon
 
182
        sleep(1)
 
183
        self.addCleanup(os.remove, tempFile + '.tar.gz')       
127
184
        
128
185
def _generateTempFileName():
129
186
    #Create temporary file, then close it, so we can re-use the file name