示例#1
0
    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()
示例#2
0
    def testItShouldNotBeValidIfNoActionOrComponentIsSet(self):
        reflector = IntentTestCase.MockReflector()
        reflector.construct_returns = ReflectedObject(999, reflector=reflector)
        module = IntentTestCase.MockModule(reflector)

        intent = Intent()
        
        assert not intent.isValid()
示例#3
0
    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()
示例#4
0
    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()
示例#5
0
    def testItShouldNotBeValidIfNoActionOrComponentIsSet(self):
        reflector = IntentTestCase.MockReflector()
        reflector.construct_returns = ReflectedObject(999, reflector=reflector)
        module = IntentTestCase.MockModule(reflector)

        intent = Intent()

        assert not intent.isValid()
示例#6
0
    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()
示例#7
0
    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"
示例#8
0
    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
示例#9
0
    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"
示例#10
0
    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
示例#11
0
    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"
示例#12
0
    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"
示例#13
0
    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"
示例#14
0
    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"
示例#15
0
    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"
示例#16
0
    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"
示例#17
0
    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"
示例#18
0
    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"