~om26er/ubuntu-filemanager-app/fix_toolbar_icons

« back to all changes in this revision

Viewing changes to tests/autopilot/ubuntu_filemanager_app/tests/test_filemanager.py

  • Committer: Tarmac
  • Author(s): Leo Arias
  • Date: 2013-06-27 09:04:48 UTC
  • mfrom: (34.2.8 trunk)
  • Revision ID: tarmac-20130627090448-2iuo38y5ltigo14e
Added the test to open a directory. Fixes: https://bugs.launchpad.net/bugs/1188732.

Approved by Ubuntu Phone Apps Jenkins Bot, Arto Jalkanen.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 
10
10
from __future__ import absolute_import
11
11
 
 
12
import tempfile
 
13
 
 
14
import mock
 
15
import os
 
16
import shutil
 
17
 
12
18
from autopilot.matchers import Eventually
13
19
from testtools.matchers import Equals
14
20
 
18
24
class TestMainWindow(FileManagerTestCase):
19
25
 
20
26
    def setUp(self):
 
27
        self._patch_home()
21
28
        super(TestMainWindow, self).setUp()
22
29
        self.assertThat(
23
 
            self.main_window.get_qml_view().visible, Eventually(Equals(True)))
 
30
            self.ubuntusdk.get_qml_view().visible, Eventually(Equals(True)))
24
31
 
25
 
    def tearDown(self):
26
 
        super(TestMainWindow, self).tearDown()
 
32
    def _patch_home(self):
 
33
        temp_dir = tempfile.mkdtemp()
 
34
        self.addCleanup(shutil.rmtree, temp_dir)
 
35
        patcher = mock.patch.dict('os.environ', {'HOME': temp_dir})
 
36
        patcher.start()
 
37
        self.addCleanup(patcher.stop)
27
38
 
28
39
    def test_toolbar_shows(self):
29
 
        """Make sure that dragging from the bottom reveals the hidden
30
 
        toolbar."""
 
40
        """Dragging from the bottom reveals the hidden toolbar."""
 
41
        self._make_directory_in_home()
 
42
 
31
43
        first_folder = self.main_window.get_folder(0)
32
44
        self.tap_item(first_folder)
33
45
 
34
46
        action_popover = self.main_window.get_action_popover()
35
47
        self.assertThat(lambda: action_popover.opacity, Eventually(Equals(1)))
 
48
 
 
49
    def _make_directory_in_home(self):
 
50
        path = tempfile.mkdtemp(dir=os.environ['HOME'])
 
51
        # Currently, we need to open again the home folder to show the newly
 
52
        # created one. See bug #1190676.
 
53
        # TODO when the bug is fixed, remove the next line.
 
54
        self.ubuntusdk.click_toolbar_button('Home')
 
55
        return path
 
56
 
 
57
    def test_open_directory(self):
 
58
        sub_dir = self._make_directory_in_home()
 
59
 
 
60
        first_folder = self.main_window.get_folder(0)
 
61
        self.pointing_device.click_object(first_folder)
 
62
        self.assertThat(
 
63
            self.main_window.get_current_folder_name,
 
64
            Eventually(Equals(sub_dir)))