コード例 #1
0
 def test_deploy(self):
     device = Device("emulator-5554")
     self.assertTrue(self.call_log_env.deploy(device))
     self.assertTrue(self.contact_env.deploy(device))
     self.assertTrue(self.gps_env.deploy(device))
     self.assertTrue(self.settings_env.deploy(device))
     self.assertTrue(self.sms_log_env.deploy(device))
     device.disconnect()
コード例 #2
0
ファイル: test_app_event.py プロジェクト: hugo-glez/droidbot
 def test_send(self):
     device = Device("emulator-5554")
     self.assertTrue(self.touch_event.send(device))
     self.assertTrue(self.intent_event.send(device))
     self.assertTrue(self.long_touch_event.send(device))
     self.assertTrue(self.key_event.send(device))
     self.assertTrue(self.emulator_event.send(device))
     self.assertTrue(self.drag_event.send(device))
     self.assertTrue(self.context_event1.send(device))
     device.disconnect()
コード例 #3
0
ファイル: test_app_event.py プロジェクト: tenyee/droidbot
 def test_send(self):
     device = Device("emulator-5554")
     self.assertTrue(self.touch_event.send(device))
     self.assertTrue(self.intent_event.send(device))
     self.assertTrue(self.long_touch_event.send(device))
     self.assertTrue(self.key_event.send(device))
     self.assertTrue(self.emulator_event.send(device))
     self.assertTrue(self.drag_event.send(device))
     self.assertTrue(self.context_event1.send(device))
     device.disconnect()
コード例 #4
0
ファイル: test_app_event.py プロジェクト: hugo-glez/droidbot
    def test_context(self):
        device = Device("emulator-5554")
        self.assertFalse(self.activity_context.assert_in_device(device))
        self.assertFalse(self.window_context.assert_in_device(device))

        settings_activity_context = ActivityNameContext("com.android.settings/.Settings")
        settings_window_context = WindowNameContext("com.android.settings/com.android.settings.Settings")
        device.start_app("com.android.settings")
        time.sleep(2)
        self.assertTrue(settings_activity_context.assert_in_device(device))
        self.assertTrue(settings_window_context.assert_in_device(device))

        device.disconnect()
コード例 #5
0
class TestADB(unittest.TestCase):
    def setUp(self):
        self.device=Device("emulator-5554")
        self.adb = ADB(self.device)

    def test_connect(self):
        self.assertTrue(self.adb.check_connectivity())

    def test_run_cmd(self):
        r = self.adb.run_cmd(['get-state'])
        self.assertTrue(r.startswith('device'))
        r = self.adb.run_cmd("get-state")
        self.assertTrue(r.startswith('device'))

    def tearDown(self):
        self.adb.disconnect()
        self.device.disconnect()
コード例 #6
0
class TestTelnet(unittest.TestCase):
    def setUp(self):
        self.device=Device("emulator-5554")
        self.telnet = TelnetConsole(self.device)

    def test_connect(self):
        self.assertTrue(self.telnet.check_connectivity())
        self.telnet.disconnect()

    def test_run_cmd(self):
        self.assertTrue(self.telnet.run_cmd("help"))
        self.assertTrue(self.telnet.run_cmd(['help']))
        self.assertFalse(self.telnet.run_cmd("unknown"))

    def tearDown(self):
        self.telnet.disconnect()
        self.device.disconnect()
コード例 #7
0
ファイル: test_app_event.py プロジェクト: tenyee/droidbot
    def test_context(self):
        device = Device("emulator-5554")
        self.assertFalse(self.activity_context.assert_in_device(device))
        self.assertFalse(self.window_context.assert_in_device(device))

        settings_activity_context = ActivityNameContext(
            "com.android.settings/.Settings")
        settings_window_context = WindowNameContext(
            "com.android.settings/com.android.settings.Settings")
        device.start_app("com.android.settings")
        time.sleep(2)
        self.assertTrue(settings_activity_context.assert_in_device(device))
        self.assertTrue(settings_window_context.assert_in_device(device))

        device.disconnect()
コード例 #8
0
ファイル: test_types.py プロジェクト: tenyee/droidbot
class DeviceTest(unittest.TestCase):
    """
    test the Device class,
    before testing, please make sure a emulator is started
    """
    def setUp(self):
        self.device = Device("emulator-5554")

    def tearDown(self):
        self.device.disconnect()
        self.device = None

    def test_init(self):
        self.assertTrue(self.device.is_connected)
        self.assertIsNotNone(self.device.get_display_info())

        device_real = Device("emulator-5554", is_emulator=False)
        self.assertTrue(device_real.is_connected)

    def test_connect(self):
        if self.device.is_emulator:
            self.assertIsNotNone(self.device.get_adb())
            self.assertIsNotNone(self.device.get_telnet())
            self.assertIsNotNone(self.device.get_view_client())
        else:
            self.assertIsNotNone(self.device.get_adb())
            self.assertIsNotNone(self.device.get_telnet())
        self.device.check_connectivity()
        self.device.disconnect()
        self.device.connect()
        self.assertTrue(self.device.is_connected)

    def test_is_foreground(self):
        settings_app = App(package_name="com.android.settings")
        no_app = App()
        self.device.get_adb().press('HOME')
        time.sleep(2)
        self.assertTrue(self.device.is_foreground(no_app))
        self.assertFalse(self.device.is_foreground(settings_app))

        self.device.start_app(settings_app)
        time.sleep(2)
        self.assertTrue(settings_app)
        self.assertFalse(self.device.is_foreground("com.android.unknown"))

    def test_add_contact(self):
        contact_data = {'name': 'Lynn', 'phone': '1234567890'}
        r = self.device.add_contact(contact_data)
        self.assertTrue(r)

    def test_call(self):
        phone_num = "1234567890"

        r = self.device.call(phone_num)
        self.assertTrue(r)
        time.sleep(2)

        r = self.device.cancel_call(phone_num)
        self.assertTrue(r)
        time.sleep(2)

        r = self.device.receive_call(phone_num)
        self.assertTrue(r)
        time.sleep(2)

        r = self.device.accept_call(phone_num)
        self.assertTrue(r)
        time.sleep(2)

        r = self.device.cancel_call(phone_num)
        self.assertTrue(r)

    def test_sms(self):
        r = self.device.send_sms()
        self.assertTrue(r)

        r = self.device.receive_sms()
        self.assertTrue(r)

    def test_set_gps(self):
        r = self.device.set_gps(10, 10)
        self.assertTrue(r)

    def test_settings(self):
        self.device.change_settings(table_name='system',
                                    name='volume_system',
                                    value='10')
        self.assertEqual(self.device.get_settings()['system']['volume_system'],
                         '10')
        self.device.change_settings(table_name='system',
                                    name='volume_system',
                                    value='20')
        self.assertEqual(self.device.get_settings()['system']['volume_system'],
                         '20')
コード例 #9
0
ファイル: test_types.py プロジェクト: tenyee/droidbot
    def test_init(self):
        self.assertTrue(self.device.is_connected)
        self.assertIsNotNone(self.device.get_display_info())

        device_real = Device("emulator-5554", is_emulator=False)
        self.assertTrue(device_real.is_connected)
コード例 #10
0
ファイル: test_types.py プロジェクト: tenyee/droidbot
 def setUp(self):
     self.device = Device("emulator-5554")
コード例 #11
0
ファイル: test_types.py プロジェクト: hugo-glez/droidbot
class DeviceTest(unittest.TestCase):
    """
    test the Device class,
    before testing, please make sure a emulator is started
    """
    def setUp(self):
        self.device = Device("emulator-5554")

    def tearDown(self):
        self.device.disconnect()
        self.device = None

    def test_init(self):
        self.assertTrue(self.device.is_connected)
        self.assertIsNotNone(self.device.get_display_info())

        device_real = Device("emulator-5554", is_emulator=False)
        self.assertTrue(device_real.is_connected)

    def test_connect(self):
        if self.device.is_emulator:
            self.assertIsNotNone(self.device.get_adb())
            self.assertIsNotNone(self.device.get_telnet())
            self.assertIsNotNone(self.device.get_view_client())
        else:
            self.assertIsNotNone(self.device.get_adb())
            self.assertIsNotNone(self.device.get_telnet())
        self.device.check_connectivity()
        self.device.disconnect()
        self.device.connect()
        self.assertTrue(self.device.is_connected)

    def test_is_foreground(self):
        settings_app = App(package_name="com.android.settings")
        no_app = App()
        self.device.get_adb().press('HOME')
        time.sleep(2)
        self.assertTrue(self.device.is_foreground(no_app))
        self.assertFalse(self.device.is_foreground(settings_app))

        self.device.start_app(settings_app)
        time.sleep(2)
        self.assertTrue(settings_app)
        self.assertFalse(self.device.is_foreground("com.android.unknown"))

    def test_add_contact(self):
        contact_data = {
            'name': 'Lynn',
            'phone': '1234567890'
        }
        r = self.device.add_contact(contact_data)
        self.assertTrue(r)

    def test_call(self):
        phone_num = "1234567890"

        r = self.device.call(phone_num)
        self.assertTrue(r)
        time.sleep(2)

        r = self.device.cancel_call(phone_num)
        self.assertTrue(r)
        time.sleep(2)

        r = self.device.receive_call(phone_num)
        self.assertTrue(r)
        time.sleep(2)

        r = self.device.accept_call(phone_num)
        self.assertTrue(r)
        time.sleep(2)

        r = self.device.cancel_call(phone_num)
        self.assertTrue(r)

    def test_sms(self):
        r = self.device.send_sms()
        self.assertTrue(r)

        r = self.device.receive_sms()
        self.assertTrue(r)

    def test_set_gps(self):
        r = self.device.set_gps(10, 10)
        self.assertTrue(r)

    def test_settings(self):
        self.device.change_settings(table_name='system', name='volume_system', value='10')
        self.assertEqual(self.device.get_settings()['system']['volume_system'], '10')
        self.device.change_settings(table_name='system', name='volume_system', value='20')
        self.assertEqual(self.device.get_settings()['system']['volume_system'], '20')
コード例 #12
0
ファイル: test_types.py プロジェクト: hugo-glez/droidbot
 def setUp(self):
     self.device = Device("emulator-5554")
コード例 #13
0
ファイル: droidbot_demo.py プロジェクト: tenyee/droidbot
__author__ = 'yuanchun'

from droidbot.droidbot_types import Device, App
from droidbot.app_event import CustomizedEventFactory, AppEventManager, AppEvent


class MyEventFactory(CustomizedEventFactory):
    def gen_event_based_on_state(self, state):
        print state
        return AppEvent.get_random_instance(self.device, self.app)


if __name__ == "__main__":
    d = Device()
    a = App(app_path="/home/liyc/experiments/apks/hot_apks_types/Personalization/net.zedge.android.apk")
    event_manager = AppEventManager(device=d, app=a, event_policy="none", event_count=100, event_interval=3,
                                    event_duration=100)
    event_manager.set_event_factory(MyEventFactory(d, a))
    d.install_app(a)
    event_manager.start()
    d.uninstall_app(a)
コード例 #14
0
 def setUp(self):
     self.device=Device("emulator-5554")
     self.adb = ADB(self.device)
コード例 #15
0
 def setUp(self):
     self.device=Device("emulator-5554")
     self.telnet = TelnetConsole(self.device)