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"))
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")
def setUp(self): self.app = App(app_path="resources/DroidBoxTests.apk")
__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)