1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
# Copyright 2012 Canonical
3
# Author: Iftikhar Ahmad
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
15
class RemoteSystemLoginTests(AutopilotTestCase):
19
cls.app_proxy = make_proxy_object_from_service_name("org.gnome.ScreenSaver","/com/canonical/Autopilot/Introspection")
22
def tearDownClass(cls):
23
cls.app_proxy.set_process(None)
26
super(RemoteSystemLoginTests, self).setUp()
30
super(RemoteSystemLoginTests, self).tearDown()
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]
41
self.promptBox = self.app_proxy.select_single('//PromptBox', label='Remote Login')
42
self.assertTrue(self.promptBox is not None)
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]
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)
54
self.keyboard.type('remotelogin6@gmail.com')
55
self.mouse.move_to_object(pswd)
58
self.keyboard.type('Abcd%1234')
60
self.keyboard.press_and_release('Enter')
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)
70
self.keyboard.press_and_release('Enter')
73
def wait_for_single_object(self, object_name, timeout, **kwargs):
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)
82
def wait_for_multiple_objects(self, object_name, object_count, timeout, **kwargs):
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)):
91
if __name__ == '__main__':