def testItShouldBeValidIfTheComponentIsSet(self): reflector = IntentTestCase.MockReflector() reflector.construct_returns = ReflectedObject(999, reflector=reflector) module = IntentTestCase.MockModule(reflector) intent = Intent(component="com.android.browser com.android.browser.BrowserActivity") assert intent.isValid()
def testItShouldNotBeValidIfNoActionOrComponentIsSet(self): reflector = IntentTestCase.MockReflector() reflector.construct_returns = ReflectedObject(999, reflector=reflector) module = IntentTestCase.MockModule(reflector) intent = Intent() assert not intent.isValid()
def testItShouldBeValidIfTheActionIsSet(self): reflector = IntentTestCase.MockReflector() reflector.construct_returns = ReflectedObject(999, reflector=reflector) module = IntentTestCase.MockModule(reflector) intent = Intent(action="android.intent.action.VIEW") assert intent.isValid()
def testItShouldBeValidIfTheComponentIsSet(self): reflector = IntentTestCase.MockReflector() reflector.construct_returns = ReflectedObject(999, reflector=reflector) module = IntentTestCase.MockModule(reflector) intent = Intent( component="com.android.browser com.android.browser.BrowserActivity" ) assert intent.isValid()
def testItShouldBuildTheAction(self): reflector = IntentTestCase.MockReflector() reflector.construct_returns = ReflectedObject(999, reflector=reflector) module = IntentTestCase.MockModule(reflector) intent = Intent(action="com.android.intent.VIEW") intent.buildIn(module) assert reflector.invoked[-1][1] == "setAction" assert reflector.invoked[-1][2][0] == "com.android.intent.VIEW"
def testItShouldBuildTheFlagsFromBinaryAndSymbols(self): reflector = IntentTestCase.MockReflector() reflector.construct_returns = ReflectedObject(999, reflector=reflector) module = IntentTestCase.MockModule(reflector) intent = Intent(flags=["ACTIVITY_NEW_TASK", "0x00010000"]) intent.buildIn(module) assert reflector.invoked[-1][1] == "setFlags" assert reflector.invoked[-1][2][0] == 0x10010000
def testItShouldAddStringExtras(self): reflector = IntentTestCase.MockReflector() reflector.construct_returns = ReflectedObject(999, reflector=reflector) module = IntentTestCase.MockModule(reflector) intent = Intent(extras=[("string", "myString", "Hello, World!")]) intent.buildIn(module) assert reflector.invoked[0][1] == "putString" assert reflector.invoked[0][2][0] == "myString" assert reflector.invoked[0][2][1] == "Hello, World!" assert reflector.invoked[1][1] == "putExtras"
def testItShouldAddIntegerExtras(self): reflector = IntentTestCase.MockReflector() reflector.construct_returns = ReflectedObject(999, reflector=reflector) module = IntentTestCase.MockModule(reflector) intent = Intent(extras=[("integer", "myInt", 42)]) intent.buildIn(module) assert reflector.invoked[0][1] == "putInt" assert reflector.invoked[0][2][0] == "myInt" assert reflector.invoked[0][2][1] == 42 assert reflector.invoked[1][1] == "putExtras"
def testItShouldAddBooleanExtras(self): reflector = IntentTestCase.MockReflector() reflector.construct_returns = ReflectedObject(999, reflector=reflector) module = IntentTestCase.MockModule(reflector) intent = Intent(extras=[('boolean', 'myBool', "True")]) intent.buildIn(module) assert reflector.invoked[0][1] == "putBoolean" assert reflector.invoked[0][2][0] == 'myBool' assert reflector.invoked[0][2][1] == True assert reflector.invoked[1][1] == "putExtras"
def testItShouldAddBooleanExtras(self): reflector = IntentTestCase.MockReflector() reflector.construct_returns = ReflectedObject(999, reflector=reflector) module = IntentTestCase.MockModule(reflector) intent = Intent(extras=[('boolean', 'myBool', True)]) intent.buildIn(module) assert reflector.invoked[0][1] == "putBoolean" assert reflector.invoked[0][2][0] == 'myBool' assert reflector.invoked[0][2][1] == True assert reflector.invoked[1][1] == "putExtras"
def testItShouldAddFloatExtras(self): reflector = IntentTestCase.MockReflector() reflector.construct_returns = ReflectedObject(999, reflector=reflector) module = IntentTestCase.MockModule(reflector) intent = Intent(extras=[("float", "myFloat", 3.14)]) intent.buildIn(module) assert reflector.invoked[0][1] == "putFloat" assert reflector.invoked[0][2][0] == "myFloat" assert reflector.invoked[0][2][1] == 3.14 assert reflector.invoked[1][1] == "putExtras"