~osomon/webbrowser-app/uriboni-tab-context-menu

« back to all changes in this revision

Viewing changes to tests/autopilot/kalossi_browser/tests/test_mainwindow.py

  • Committer: Michael Zanetti
  • Date: 2013-01-14 15:47:33 UTC
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: michael_zanetti@gmx.net-20130114154733-99esebl4s4f242ym
Added initial autopilot tests and autopilot package

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
# Copyright 2012 Canonical
 
3
#
 
4
# This program is free software: you can redistribute it and/or modify it
 
5
# under the terms of the GNU General Public License version 3, as published
 
6
# by the Free Software Foundation.
 
7
 
 
8
"""Tests for the Browser"""
 
9
 
 
10
from __future__ import absolute_import
 
11
 
 
12
from testtools.matchers import Equals, NotEquals, GreaterThan
 
13
from autopilot.matchers import Eventually
 
14
 
 
15
from kalossi_browser.tests import BrowserTestCase
 
16
 
 
17
import unittest
 
18
import time
 
19
import os
 
20
from os import path
 
21
 
 
22
class TestMainWindow(BrowserTestCase):
 
23
    """Tests the main browser features"""
 
24
 
 
25
    """ This is needed to wait for the application to start.
 
26
        In the testfarm, the application may take some time to show up."""
 
27
    def setUp(self):
 
28
        super(TestMainWindow, self).setUp()
 
29
        self.assertThat(self.main_window.get_qml_view().visible, Eventually(Equals(True)))
 
30
 
 
31
    def tearDown(self):
 
32
        super(TestMainWindow, self).tearDown()
 
33
 
 
34
    """Test opening a website"""
 
35
    def test_open_website(self):
 
36
        address_bar = self.main_window.get_address_bar()
 
37
        self.pointing_device.move_to_object(address_bar)
 
38
        self.pointing_device.click()
 
39
        address_bar_clear_button = self.main_window.get_address_bar_clear_button()
 
40
        self.pointing_device.move_to_object(address_bar_clear_button)
 
41
        self.pointing_device.click()
 
42
        self.pointing_device.move_to_object(address_bar)
 
43
        self.pointing_device.click()
 
44
 
 
45
        self.keyboard.type("http://www.canonical.com")
 
46
        self.keyboard.press("Enter")
 
47
 
 
48
        web_view = self.main_window.get_web_view()
 
49
        self.assertThat(web_view.url, Eventually(Equals("http://www.canonical.com/")))