~iahmad/+junk/thinclient-tests

« back to all changes in this revision

Viewing changes to thinclient/tests/test_remotesystemlogin.py

  • Committer: Iftikhar Ahmad
  • Date: 2013-01-17 13:11:57 UTC
  • Revision ID: iftikhar.ahmad@gmail.com-20130117131157-82wkj6ero70gzhfw
remotesystelogin-test-1

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
# Author: Iftikhar Ahmad
 
4
 
 
5
 
 
6
import subprocess
 
7
import unittest
 
8
import time
 
9
 
 
10
from autopilot.testcase import AutopilotTestCase
 
11
from autopilot.introspection.gtk import GtkIntrospectionTestMixin
 
12
from thinclient.emulators import ensure_unity_greeter_is_running
 
13
from autopilot.introspection import make_proxy_object_from_service_name
 
14
 
 
15
class RemoteSystemLoginTests(AutopilotTestCase):
 
16
 
 
17
    @classmethod
 
18
    def setUpClass(cls):
 
19
        cls.app_proxy = make_proxy_object_from_service_name("org.gnome.ScreenSaver","/com/canonical/Autopilot/Introspection")
 
20
 
 
21
    @classmethod    
 
22
    def tearDownClass(cls):
 
23
        cls.app_proxy.set_process(None)
 
24
 
 
25
    def setUp(self):
 
26
        super(RemoteSystemLoginTests, self).setUp()
 
27
        self.reset()
 
28
 
 
29
    def tearDown(self):
 
30
        super(RemoteSystemLoginTests, self).tearDown()
 
31
        self.reset()
 
32
 
 
33
    def reset(self):
 
34
        ensure_unity_greeter_is_running()        
 
35
        gs = self.app_proxy.select_single('//UserPromptBox', label='Guest Session')
 
36
        self.assertTrue(gs is not None)
 
37
        (x, y) = gs.globalRect[0], gs.globalRect[1]
 
38
        self.mouse.move(x, y)
 
39
        self.mouse.click()
 
40
        time.sleep(1)        
 
41
        self.promptBox = self.app_proxy.select_single('//PromptBox', label='Remote Login')
 
42
        self.assertTrue(self.promptBox is not None) 
 
43
 
 
44
    def test_login_remote_system_over_ethernet(self): #LOGIN-TO-REMOTE-SYSTEM-0002
 
45
        (x, y) = self.promptBox.globalRect[0], self.promptBox.globalRect[1]
 
46
        self.mouse.move(x, y)
 
47
        self.mouse.click()
 
48
        time.sleep(1)
 
49
        email = self.app_proxy.select_single('//DashEntry', constant_placeholder_text='Email address')        
 
50
        pswd = self.app_proxy.select_single('//DashEntry', constant_placeholder_text='Password')
 
51
        self.mouse.move_to_object(email)
 
52
        self.mouse.click()
 
53
        time.sleep(1)
 
54
        self.keyboard.type('remotelogin6@gmail.com') 
 
55
        self.mouse.move_to_object(pswd)
 
56
        self.mouse.click()
 
57
        time.sleep(1)
 
58
        self.keyboard.type('Abcd%1234')
 
59
        time.sleep(1)      
 
60
        self.keyboard.press_and_release('Enter')
 
61
        
 
62
        #import pdb; pdb.set_trace()
 
63
        prompt = self.wait_for_single_object('//PromptBox', 10, label='RDP1') 
 
64
        self.assertTrue(prompt is not None)
 
65
        rdp1_username = prompt.select_single('//DashEntry', constant_placeholder_text='Username')
 
66
        rdp1_password = prompt.select_single('//DashEntry', constant_placeholder_text='Password')
 
67
        self.mouse.move_to_object(rdp1_password)
 
68
        self.mouse.click()
 
69
        time.sleep(1)
 
70
        self.keyboard.press_and_release('Enter')
 
71
        time.sleep(10)
 
72
 
 
73
    def wait_for_single_object(self, object_name, timeout, **kwargs):
 
74
        obj = None
 
75
        for i in range(timeout):
 
76
            time.sleep(1) #check after every sec if object is updated on screen until the timeout value reached.
 
77
            obj = self.app_proxy.select_single(object_name, **kwargs)
 
78
            if( obj is not None):
 
79
                break
 
80
        return obj
 
81
    
 
82
    def wait_for_multiple_objects(self, object_name, object_count, timeout, **kwargs):
 
83
        obj = []
 
84
        for i in range(timeout):
 
85
            time.sleep(1) #check after every sec if object is updated on screen until the timeout value reached.
 
86
            obj = self.app_proxy.select_many(object_name, **kwargs)
 
87
            if( obj is not None and (obj.__len__() >= object_count)):
 
88
                break
 
89
        return obj
 
90
 
 
91
if __name__ == '__main__':
 
92
  unittest.main()