~ubuntu-branches/ubuntu/wily/webbrowser-app/wily-proposed

« back to all changes in this revision

Viewing changes to tests/autopilot/webbrowser_app/tests/test_backforward.py

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2013-06-05 05:03:05 UTC
  • Revision ID: package-import@ubuntu.com-20130605050305-qgpd9x3s01m06dca
Tags: upstream-0.20daily13.06.05
ImportĀ upstreamĀ versionĀ 0.20daily13.06.05

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#
 
3
# Copyright 2013 Canonical
 
4
#
 
5
# This program is free software: you can redistribute it and/or modify it
 
6
# under the terms of the GNU General Public License version 3, as published
 
7
# by the Free Software Foundation.
 
8
 
 
9
from __future__ import absolute_import
 
10
 
 
11
from testtools.matchers import Equals
 
12
from autopilot.matchers import Eventually
 
13
 
 
14
from webbrowser_app.tests import StartOpenLocalPageTestCaseBase
 
15
 
 
16
 
 
17
LOREMIPSUM = "<p>Lorem ipsum dolor sit amet.</p>"
 
18
 
 
19
 
 
20
class TestBackForward(StartOpenLocalPageTestCaseBase):
 
21
 
 
22
    """Tests the back and forward functionality."""
 
23
 
 
24
    def click_back_button(self):
 
25
        self.ensure_chrome_is_hidden()
 
26
        self.reveal_chrome()
 
27
        back_button = self.main_window.get_back_button()
 
28
        self.pointing_device.move_to_object(back_button)
 
29
        self.pointing_device.click()
 
30
 
 
31
    def test_homepage_no_history(self):
 
32
        back_button = self.main_window.get_back_button()
 
33
        self.assertThat(back_button.enabled, Equals(False))
 
34
        forward_button = self.main_window.get_forward_button()
 
35
        self.assertThat(forward_button.enabled, Equals(False))
 
36
 
 
37
    def test_opening_new_page_enables_back_button(self):
 
38
        back_button = self.main_window.get_back_button()
 
39
        self.assertThat(back_button.enabled, Equals(False))
 
40
        url = self.make_html_page("page 2", LOREMIPSUM)
 
41
        self.go_to_url(url)
 
42
        self.assert_page_eventually_loaded(url)
 
43
        self.assertThat(back_button.enabled, Eventually(Equals(True)))
 
44
 
 
45
    def test_navigating_back_enables_forward_button(self):
 
46
        url = self.make_html_page("page 2", LOREMIPSUM)
 
47
        self.go_to_url(url)
 
48
        self.assert_page_eventually_loaded(url)
 
49
        forward_button = self.main_window.get_forward_button()
 
50
        self.assertThat(forward_button.enabled, Equals(False))
 
51
        self.click_back_button()
 
52
        self.assert_home_page_eventually_loaded()
 
53
        self.assertThat(forward_button.enabled, Eventually(Equals(True)))