예제 #1
0
    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"))
예제 #2
0
class AppTest(unittest.TestCase):
    """
    test the App class
    """
    def setUp(self):
        self.app = App(app_path="resources/DroidBoxTests.apk")

    def test_get_package_name(self):
        package_name = self.app.get_package_name()
        self.assertEqual(package_name, "droidbox.tests")

    def test_get_main_activity(self):
        main_activity = self.app.get_main_activity()
        self.assertEqual(main_activity, "droidbox.tests.DroidBoxTests")

    def test_get_possible_broadcasts(self):
        possible_broadcasts = self.app.get_possible_broadcasts()
        self.assertIsNotNone(possible_broadcasts)
        i = possible_broadcasts.pop()
        self.assertEqual(i.action, "android.provider.Telephony.SMS_RECEIVED")
예제 #3
0
class AppTest(unittest.TestCase):
    """
    test the App class
    """
    def setUp(self):
        self.app = App(app_path="resources/DroidBoxTests.apk")

    def test_get_package_name(self):
        package_name = self.app.get_package_name()
        self.assertEqual(package_name, "droidbox.tests")

    def test_get_main_activity(self):
        main_activity = self.app.get_main_activity()
        self.assertEqual(main_activity, "droidbox.tests.DroidBoxTests")

    def test_get_possible_broadcasts(self):
        possible_broadcasts = self.app.get_possible_broadcasts()
        self.assertIsNotNone(possible_broadcasts)
        i = possible_broadcasts.pop()
        self.assertEqual(i.action, "android.provider.Telephony.SMS_RECEIVED")
예제 #4
0
class AppTest(TestCase):
    """
    test the App class
    """
    def setUp(self):
        self.app = App(app_path="resources/TestDroidbot.apk")

    def test_init(self):
        noapp = App()
        self.assertTrue(noapp.whole_device)

        app_with_file_path = self.app
        self.assertFalse(app_with_file_path.whole_device)
        self.assertEqual(app_with_file_path.get_package_name(), 'com.android.browser')

    def test_get_package_name(self):
        package_name = self.app.get_package_name()
        self.assertEqual(package_name, "com.lynnlyc")

    def test_get_app_path(self):
        from droidbot.droidbot import DroidBot
        import os
        droidbot = DroidBot(package_name="com.android.settings")
        self.assertFalse(droidbot.app.whole_device)
        app_file_path = droidbot.app.get_app_path()
        self.assertIsNotNone(app_file_path)
        self.assertTrue(os.path.exists(app_file_path))

    def test_get_main_activity(self):
        main_activity = self.app.get_main_activity()
        self.assertEqual(main_activity, "MainActivity")

    def test_get_possible_broadcasts(self):
        possible_broadcasts = self.app.get_possible_broadcasts()
        self.assertIsNotNone(possible_broadcasts)
        # TODO modify testDroidbot app, and fix this assertion
        i = Intent(prefix='broadcast', action="", category="")
        self.assertIn(i, possible_broadcasts)
예제 #5
0
 def setUp(self):
     self.app = App(app_path="resources/DroidBoxTests.apk")
예제 #6
0
__author__ = 'yuanchun'

from 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)
예제 #7
0
 def setUp(self):
     self.app = App(app_path="resources/TestDroidbot.apk")
예제 #8
0
 def setUp(self):
     self.app = App(app_path="resources/DroidBoxTests.apk")