def test_add_location_via_cache(self):
        """ tests adding a location via cached location list """

        # Select the location
        self.add_location_page.click_location(0)

        # Check locations page is now visible
        self.assertThat(self.locations_page.visible, Eventually(Equals(True)))

        # Get the list item of the added location
        list_item = self.locations_page.get_location(self.start_count)

        # Check that the name is correct
        self.assertThat(list_item.get_name(), Equals("Amsterdam"))

        # Go back to the homepage
        self.locations_page.click_back()

        # Check homepage is now visible
        self.assertThat(self.home_page.visible, Eventually(Equals(True)))

        # Check that the location was added
        self.assertThat(self.home_page.get_location_count,
                        Eventually(Equals(self.start_count + 1)))
Example #2
0
    def test_add_album_and_cancel(self):
        """Add one album, cancel it and checks if the number of albums does not
        change. Do this in the two different ways we have to cancel editing.
        """

        # Cancel by pressing back in the header
        albums = self.albums_view.number_of_albums_in_albums_view()
        self.main_view.get_header().click_action_button("addButton")
        editor = self.app.select_single(album_editor.AlbumEditor)
        editor.ensure_fully_open()
        self.main_view.get_header().click_custom_back_button()
        self.assertThat(
            lambda: self.albums_view.number_of_albums_in_albums_view(),
            Eventually(Equals(albums)))

        # Cancel by clicking outside of the album cover
        self.main_view.get_header().click_action_button("addButton")
        editor = self.app.select_single(album_editor.AlbumEditor)
        editor.ensure_fully_open()
        editor.close()

        self.assertThat(
            lambda: self.albums_view.number_of_albums_in_albums_view(),
            Eventually(Equals(albums)))
Example #3
0
    def test_launcher_keynav_expo_focus(self):
        """When entering expo mode from KeyNav the Desktop must get focus."""
        if self.workspace.num_workspaces < 2:
            self.skipTest(
                "This test requires enabled more than one workspace.")

        self.start_keynav_with_cleanup_cancel()

        self.launcher_instance.keyboard_select_icon(
            self.launcher_position, tooltip_text="Workspace Switcher")
        self.launcher_instance.key_nav_activate()
        self.addCleanup(self.keybinding, "expo/cancel")

        self.assertThat(self.unity.panels.get_active_panel().title,
                        Eventually(Equals("Ubuntu Desktop")))
Example #4
0
    def test_cut_file(self):
        # Set up a file to cut and a directory to move it into.
        destination_dir_path = self.make_directory_in_home()
        destination_dir_name = os.path.basename(destination_dir_path)
        file_to_cut_path = self.make_file_in_home()
        file_to_cut_name = os.path.basename(file_to_cut_path)

        folder_list_page = self.app.main_view.get_folder_list_page()
        self._assert_number_of_files(2)

        # Cut the file.
        file_to_cut = folder_list_page.get_file_by_name(file_to_cut_name)
        self._do_action_on_file(file_to_cut, 'Cut')

        # Go to the destination directory.
        destination_dir = folder_list_page.get_file_by_name(
            destination_dir_name)
        self._open_directory(destination_dir)

        # Paste the file.
        self.app.main_view.click_header_action('paste')

        # Check that the file is there.
        self._assert_number_of_files(1, home=False)
        first_dir = self._get_file_by_name(file_to_cut_name)
        self.assertThat(
            first_dir.fileName, Eventually(Equals(file_to_cut_name)))

        # Go back.
        self.app.main_view.click_back()

        # Check that the file is not there.
        self._assert_number_of_files(1)
        first_dir = self._get_file_by_name(destination_dir_name)
        self.assertThat(
            first_dir.fileName, Eventually(Equals(destination_dir_name)))
Example #5
0
    def test_slider_reverts_on_late_response(self):

        slider = self.indicator_page.get_slider()
        slider_menu = self.indicator_page.get_slider_menu()

        original_value = slider.value
        slider.slide_left()

        # slider should revert to original value after 5 seconds
        # (30 seconds in real usage)
        self.assertThat(slider.value,
                        Eventually(Equals(original_value), timeout=20))

        # make sure we've got the server value set.
        self.assertThat(slider.value, Equals(slider_menu.serverValue))
Example #6
0
    def test_clicked_signal_emitted(self):
        """Clicking the Switch component must emit the clicked() signal."""

        obj = self.app.select_single('Switch')
        signal = obj.watch_signal('clicked(QVariant)')

        self.assertThat(obj.checked, Equals(False))

        self.mouse.move_to_object(obj)
        self.mouse.click()

        self.assertThat(obj.checked, Eventually(Equals(True)))

        self.assertThat(signal.was_emitted, Equals(True))
        self.assertThat(signal.num_emissions, Equals(1))
 def test_hide_empty_bookmarks_folders_when_expanded(self):
     more_button = self.new_tab_view.get_bookmarks_more_button()
     self.assertThat(more_button.visible, Equals(True))
     self.pointing_device.click_object(more_button)
     folders = self.new_tab_view.get_bookmarks_folder_list_view()
     self.assertThat(lambda: len(folders.get_delegates()),
                     Eventually(Equals(3)))
     self._toggle_bookmark_folder("Actinide")
     folder_delegate = folders.get_folder_delegate("Actinide")
     self.assertThat(lambda: len(folders.get_urls_from_folder(
                                 folder_delegate)),
                     Eventually(Equals(1)))
     self._remove_first_bookmark_from_folder("Actinide")
     self.assertThat(lambda: len(folders.get_delegates()),
                     Eventually(Equals(2)))
     folder_delegate = folders.get_folder_delegate("")
     self.assertThat(lambda: len(folders.get_urls_from_folder(
                                 folder_delegate)),
                     Eventually(Equals(5)))
     self._toggle_bookmark_folder("NobleGas")
     folder_delegate = folders.get_folder_delegate("NobleGas")
     self.assertThat(lambda: len(folders.get_urls_from_folder(
                                 folder_delegate)),
                     Eventually(Equals(1)))
Example #8
0
    def test_remote_manipulation_of_name(self):
        old_names = self.obj_phone.GetSimNames()
        sim = '/ril_0'
        name = 'BAS QUX'
        new_names = old_names
        new_names[sim] = name
        self.obj_phone.Set(ACCOUNTS_PHONE_IFACE, "SimNames", new_names)
        self.dbus_mock.EmitSignal(ACCOUNTS_PHONE_IFACE, "PropertyChanged",
                                  "sv", dbus.Array(["SimNames", new_names]))

        try:
            self.assertThat(lambda: self.cellular_page.get_name(sim),
                            Eventually(StartsWith(name)))
        except Exception as e:
            raise e
    def test_crash_app_overlay_reloaded(self):
        args = []
        self.launch_webcontainer_app_with_local_http_server(
            args, '/open-close-content')
        self.get_webcontainer_window().visible.wait_for(True)

        self._click_overlay()
        self.assertThat(lambda: len(self.get_popup_overlay_views()),
                        Eventually(Equals(1)))

        self.kill_app(signal.SIGABRT)

        self.launch_webcontainer_app_with_local_http_server(
            args, '/open-close-content')
        self.get_webcontainer_window().visible.wait_for(True)

        self.assertThat(lambda: len(self.get_popup_overlay_views()),
                        Eventually(Equals(1)))

        views = self.get_popup_overlay_views()
        overlay = views[0]
        self.assertThat(
            lambda: overlay.wait_select_single(objectName="overlayWebview").
            url, Eventually(Contains('/open-close-content')))
Example #10
0
    def test_reset_launcher(self):
        gsettings = Gio.Settings.new('com.canonical.Unity.Launcher')

        favorites = gsettings.get_value('favorites')
        gsettings.set_value(
            'favorites',
            GLib.Variant('as', ['application://nautilus.desktop']))
        self.addCleanup(
            self.set_unity_launcher, gsettings, 'favorites', favorites)

        items = gsettings.get_value('items')
        gsettings.set_value(
            'items', GLib.Variant('as', ['application:///dialer-app.desktop']))
        self.addCleanup(
            self.set_unity_launcher, gsettings, 'items', items)

        self.reset_page.reset_launcher()
        self.assertThat(
            lambda: gsettings.get_value('favorites'),
            Eventually(Equals(gsettings.get_default_value('favorites'))))

        self.assertThat(
            lambda: gsettings.get_value('items'),
            Eventually(Equals(gsettings.get_default_value('items'))))
Example #11
0
    def test_add_contact_with_name_and_phone(self):
        test_contact = data.Contact(first_name='Fulano',
                                    last_name='de Tal',
                                    phones=[data.Phone.make()])

        # execute add new contact
        contact_editor = self.app.main_window.go_to_add_contact()
        contact_editor.fill_form(test_contact)

        # Save contact
        self.app.main_window.save()

        # Check if contact was added
        list_view = self.app.main_window.get_contact_list_view()
        self.assertThat(list_view.count, Eventually(Equals(1)))
Example #12
0
    def test_save_state(self):
        self.switch_to_photos_tab()

        tabs = self.main_view.select_single("Tabs")
        tab = tabs.get_current_tab()
        self.assertThat(tab.objectName, Equals("photosTab"))
        index = tab.index

        self.ensure_app_has_quit()
        self.start_app()

        tabs = self.main_view.select_single("Tabs")
        tab = tabs.get_current_tab()
        self.assertThat(tabs.selectedTabIndex, Eventually(Equals(index)))
        self.assertThat(tab.objectName, Equals("photosTab"))
Example #13
0
    def test_launcher_stays_open_after_icon_click(self):
        """Clicking on a launcher icon must not hide the launcher."""
        char_win = self.process_manager.start_app_window("Character Map")
        char_app = char_win.application

        char_icon = self.unity.launcher.model.get_icon(
            desktop_id=char_app.desktop_file)
        self.launcher_instance.click_launcher_icon(char_icon,
                                                   move_mouse_after=False)

        # Have to sleep to give the launcher time to hide (what the old behavior was)
        sleep(5)

        self.assertThat(self.launcher_instance.is_showing,
                        Eventually(Equals(True)))
Example #14
0
    def test_show_albums_page(self):
        """tests navigating to the Albums tab and displaying the album page"""

        # switch to albums tab
        albums_page = self.app.get_albums_page()
        albums_page.click_album(0)  # select album

        # get songs page album artist
        songs_page = self.app.get_songs_view()
        artist_label = songs_page.get_header_artist_label()

        # build list of tracks sorted by album
        tracks = self.tracks[:]
        tracks.sort(key=lambda track: track["album"])

        # check that the first is the same as
        self.assertThat(artist_label.text,
                        Eventually(Equals(tracks[0]["artist"])))

        # click on close button to close songs page
        self.app.main_view.go_back_wrapper()

        # check that the albums page is now visible
        self.assertThat(albums_page.visible, Eventually(Equals(True)))
Example #15
0
 def test_switch_tabs_from_tabs_view(self):
     if self.main_window.wide:
         self.skipTest("Only on narrow form factors")
     self.open_tabs(1)
     self.check_tab_number(1)
     tabs = self.open_tabs_view()
     self.main_window.press_key('Ctrl+Tab')
     self.check_tab_number(0)
     self.main_window.press_key('Ctrl+Tab')
     self.check_tab_number(1)
     self.main_window.press_key('Ctrl+Tab')
     self.check_tab_number(0)
     self.main_window.press_key('Escape')
     self.assertThat(tabs.visible, Eventually(Equals(False)))
     self.check_tab_number(0)
    def test_basic_intent_parsing(self):
        rule = 'MAP *.test.com:80 ' + self.get_base_url_hostname()
        with generate_webapp_with_scheme_filter() as webapp_install_path:
            args = ['--webappModelSearchPath=' + webapp_install_path]
            self.launch_webcontainer_app(
                args, {'UBUNTU_WEBVIEW_HOST_MAPPING_RULES': rule})
            webview = self.get_oxide_webview()
            webapp_url = 'http://www.test.com/'
            self.assertThat(webview.url, Eventually(Equals(webapp_url)))

            intent_uri = 'intent://maps.google.es/maps?ie=utf-8&gl=es\
#Intent;scheme=http;package=com.google.android.apps.maps;end'

            self.assertThat('http://maps.google.es/maps?ie=utf-8&gl=es',
                            Equals(self.get_scheme_filtered_uri(intent_uri)))
    def test_drag_tab_tabbar_nothing(self):
        '''test that dragging a tab out and in of tabbar is same'''
        window = self.app.get_windows()[0]

        # Drag tab down and then back into tab bar
        tab = self.get_tab_delegate(window, 0)
        x2, y2 = self.get_object_center(tab)

        self.drag_tab(tab, x2, y2)

        # Check we still have 1 window and 1 tab
        windows = self.app.get_windows()
        self.assertThat(len(windows), Equals(1))
        self.assertThat(lambda: len(windows[0].get_webviews()),
                        Eventually(Equals(1)))
Example #18
0
    def test_switch_reverts_on_late_response(self):

        switch = self.indicator_page.get_switcher()
        switch_menu = self.indicator_page.get_switch_menu()

        original_value = switch.checked
        switch.change_state()

        # switch should revert to original value after 5 seconds
        # (30 seconds in real usage)
        self.assertThat(switch.checked,
                        Eventually(Equals(original_value), timeout=20))

        # make sure we've got the server value set.
        self.assertThat(switch.checked, Equals(switch_menu.serverChecked))
Example #19
0
    def test_last_called_number(self):
        number = "1234567"
        formattedNumber = "1 234-567"

        number2 = "1231234567"
        formattedNumber2 = "1 231-234-567"

        self.main_view.dialer_page.call_number(number, formattedNumber)
        time.sleep(3)
        self.main_view.live_call_page.click_hangup_button()
        self.main_view.dialer_page.active.wait_for(True)

        self.main_view.dialer_page.call_number(number2, formattedNumber2)
        time.sleep(3)
        self.main_view.live_call_page.click_hangup_button()
        self.main_view.dialer_page.active.wait_for(True)

        self.main_view.dialer_page.reveal_bottom_edge_page()
        self.assertThat(self.history_list.visible, Eventually(Equals(True)))
        self.assertThat(self.history_list.count, Eventually(Equals(1)))
        historyEntry = self.get_history_for_number(number)
        self.main_view._click_button(historyEntry)
        self.assertThat(self.main_view.dialer_page.dialNumber,
                        Eventually(Equals(formattedNumber2)))
    def test_maximized_application_must_use_all_screen_width(self):
        application = self.process_manager.get_running_applications()[0]
        window = application.get_windows()[0]

        # Maximize window.
        screen = display.Display.create()
        screen_width = screen.get_screen_width()
        screen_height = screen.get_screen_height()
        window.resize(screen_width, screen_height)

        def get_window_width():
            _, _, window_width, _ = window.geometry
            return window_width

        self.assertThat(get_window_width, Eventually(Equals(screen_width)))
Example #21
0
    def test_outgoing_noanswer(self):
        """Outgoing call to a normal number, no answer"""
        number = "144"
        formattedNumber = "1 44"
        self.main_view.dialer_page.call_number(number, formattedNumber)
        self.assertThat(self.main_view.live_call_page.caller,
                        Eventually(Equals(number)))

        # If we press the hangup button too quickly it won't end the call.
        # Reported as bug http://pad.lv/1351817
        time.sleep(1)
        self.main_view.live_call_page.click_hangup_button()

        # now the live call view stays open for a few seconds after the call
        # ends, so we need to wait for the dialpad view to be active before
        # trying to interact with the bottom edge
        self.main_view.dialer_page.active.wait_for(True)

        # log should show call to the phone number
        self.main_view.dialer_page.reveal_bottom_edge_page()
        self.assertThat(self.history_list.count, Eventually(Equals(1)))
        # because of the bottom edge tree structure, multiple copies of the
        # same item are returned, so just use the first one
        self.assertThat(self.get_history_for_number(number), NotEquals(None))
Example #22
0
    def test_zoom_reset_on_camera_change(self):
        zoom_control = self.main_window.get_zoom_control()
        zoom_slider = self.main_window.get_zoom_slider()

        self.activate_zoom()
        x, y, w, h = zoom_slider.globalRect
        tx = x + (w // 2)
        ty = y + (h // 2)
        self.pointing_device.drag(tx, ty, (tx + zoom_control.width), ty)
        self.assertThat(zoom_control.value,
                        Eventually(Equals(zoom_control.maximumValue)))

        self.main_window.switch_cameras()
        self.assertThat(zoom_control.value,
                        Eventually(Equals(zoom_control.minimumValue)))

        self.activate_zoom()
        self.pointing_device.drag(tx, ty, (tx + zoom_control.width), ty)
        self.assertThat(zoom_control.value,
                        Eventually(Equals(zoom_control.maximumValue)))

        self.main_window.switch_cameras()
        self.assertThat(zoom_control.value,
                        Eventually(Equals(zoom_control.minimumValue)))
Example #23
0
    def test_scroll_to_new_message(self):
        """Verify that the view is scrolled to display a new message"""
        # use the number of an existing thread to avoid OSD problems
        self.number = '08155'
        messages_page = self.main_page.open_thread(self.number)

        # scroll the list to display older messages
        messages_page.scroll_list()

        # now receive a new message
        self.receive_messages(1)

        # and make sure that the list gets scrolled to the new message again
        list_view = messages_page.get_list_view()
        self.assertThat(list_view.atYEnd, Eventually(Equals(True)))
Example #24
0
    def test_can_type_string(self):
        """Typing text must produce the expected characters in the input
        field.

        """

        text_area = self.launch_test_input_area()
        keyboard = Keyboard.create('OSK')
        pointer = Pointer(Touch.create())
        pointer.click_object(text_area)
        keyboard._keyboard.wait_for_keyboard_ready()

        keyboard.type(self.input)

        self.assertThat(text_area.text, Eventually(Equals(self.input)))
    def test_show_today_details(self):
        """tests clicking on the today info to expand and contract it"""

        # Get the HomeTempInfo component from the selected pane
        location_pane = self.home_page.get_selected_location_pane()
        home_temp_info = location_pane.get_home_temp_info()

        # Check that the extra info is not shown
        self.assertThat(home_temp_info.state, Eventually(Equals("normal")))

        # Click the HomeTempInfo to show the extra info
        location_pane.click_home_temp_info()

        # Re-get HomeTempInfo as change in loaders changes tree
        home_temp_info = location_pane.get_home_temp_info()

        # Wait for the height of the HomeTempInfo to grow
        # Re-get the home temp info in the wait as the expandedHeight changes
        home_temp_info.height.wait_for(
            location_pane.get_home_temp_info().expandedHeight)

        # Check that the state and height of the HomeTempInfo have changed
        self.assertThat(home_temp_info.state, Eventually(Equals("expanded")))
        self.assertEqual(home_temp_info.height, home_temp_info.expandedHeight)
Example #26
0
    def test_next_previous(self):
        """ Test going to next track (Music Library must exist) """

        self.app.populate_queue()  # populate queue

        now_playing_page = self.app.get_now_playing_page()

        # check the track was playing
        self.assertThat(self.player.isPlaying, Eventually(Equals(True)))

        # select pause and check the player has stopped
        now_playing_page.click_play_button()
        self.assertThat(self.player.isPlaying, Eventually(Equals(False)))

        # save original song data for later
        orig_title = self.player.currentMeta.title
        orig_artist = self.player.currentMeta.author
        logger.debug("Original Song %s, %s" % (orig_title, orig_artist))

        now_playing_page.set_shuffle(False)  # ensure shuffe is off

        # goal is to go back and forth and ensure 2 different songs
        now_playing_page.click_forward_button()

        # check the player is still stopped
        self.assertThat(self.player.isPlaying, Eventually(Equals(False)))

        # ensure different song
        self.assertThat(self.player.currentMeta.title,
                        Eventually(NotEquals(orig_title)))
        self.assertThat(self.player.currentMeta.author,
                        Eventually(NotEquals(orig_artist)))

        logger.debug(
            "Next Song %s, %s" %
            (self.player.currentMeta.title, self.player.currentMeta.author))

        # select previous and ensure the track is stopped
        now_playing_page.click_previous_button()
        self.assertThat(self.player.isPlaying, Eventually(Equals(False)))

        # ensure we're back to original song
        self.assertThat(self.player.currentMeta.title,
                        Eventually(Equals(orig_title)))
        self.assertThat(self.player.currentMeta.author,
                        Eventually(Equals(orig_artist)))
Example #27
0
    def test_spread_filter(self):
        """Test spread filter"""
        cal_wins = self.start_test_application_windows("Calculator", 2)
        char_wins = self.start_test_application_windows("Character Map", 2)
        self.initiate_spread_for_screen()
        spread_filter = self.get_spread_filter()
        self.assertThat(spread_filter.visible, Eventually(Equals(False)))

        self.addCleanup(self.keyboard.press_and_release, "Escape")
        self.keyboard.type(cal_wins[0].title)
        self.assertThat(spread_filter.visible, Eventually(Equals(True)))
        self.assertThat(spread_filter.search_bar.search_string,
                        Eventually(Equals(cal_wins[0].title)))

        for w in cal_wins + char_wins:
            self.assertWindowIsScaledEquals(w.x_id, (w in cal_wins))

        self.keyboard.press_and_release("Escape")
        self.assertThat(spread_filter.visible, Eventually(Equals(False)))
        self.assertThat(spread_filter.search_bar.search_string,
                        Eventually(Equals("")))

        for w in cal_wins + char_wins:
            self.assertWindowIsScaledEquals(w.x_id, True)
    def test_clicked_signal_not_emitted(self):
        """Clicking a disabled CheckBox must not emit the clicked() signal."""

        obj = self.app.select_single('CheckBox')
        signal = obj.watch_signal('clicked(QVariant)')

        self.assertThat(obj.checked, Equals(False))

        self.mouse.move_to_object(obj)
        self.mouse.click()

        self.assertThat(obj.checked, Eventually(Equals(False)))

        self.assertThat(signal.was_emitted, Equals(False))
        self.assertThat(signal.num_emissions, Equals(0))
Example #29
0
    def test_modal_sd_without_greeter(self):
        """Snap-decision should block input to shell
           without greeter/lockscreen.
        """
        self.launch_unity()
        unlock_unity()

        summary = "Incoming file"
        body = "Frank would like to send you the file: essay.pdf"
        icon_path = "sync-idle"
        hints = [
            ("x-canonical-snap-decisions", "true"),
            ("x-canonical-non-shaped-icon", "true"),
            ("x-canonical-private-affirmative-tint", "true"),
            ("x-canonical-private-rejection-tint", "true"),
        ]

        actions = [
            ('action_accept', 'Accept'),
            ('action_decline_1', 'Decline'),
        ]

        self._create_interactive_notification(
            summary,
            body,
            icon_path,
            "NORMAL",
            actions,
            hints
        )

        # verify that we cannot reveal the launcher (no longer interact with
        # the shell)
        time.sleep(1)
        self.main_window.show_dash_swiping()
        self.assertThat(
            self.main_window.is_launcher_open, Eventually(Equals(False)))

        # verify and interact with the triggered snap-decision notification
        notify_list = self._get_notifications_list()
        get_notification = lambda: notify_list.wait_select_single(
            'Notification', objectName='notification0')
        notification = get_notification()
        self._assert_notification(
            notification, summary, body, True, False, 1.0)
        notification.pointing_device.click_object(
            notification.select_single(objectName="notify_button0"))
        self.assert_notification_action_id_was_called("action_accept")
Example #30
0
 def _start_video_capture(self, test_id):
     args = self.get_capture_command_line()
     self._capture_file = os.path.join(self.recording_directory,
                                       '%s.ogv' % (test_id))
     _ensure_directory_exists_but_not_file(self._capture_file)
     args.append(self._capture_file)
     video_session_pattern = '/tmp/rMD-session*'
     orig_sessions = glob.glob(video_session_pattern)
     logger.debug("Starting: %r", args)
     self._capture_process = subprocess.Popen(args,
                                              stdout=subprocess.PIPE,
                                              stderr=subprocess.STDOUT,
                                              universal_newlines=True)
     # wait until rmd session directory is created
     Eventually(NotEquals(orig_sessions)).match(
         lambda: glob.glob(video_session_pattern))