#NEWLINE# def test_run_android_apk( self ) : #NEWLINE# #INDENT# os . path . exists = ( lambda unused_filename : True ) #NEWLINE# __builtin__ . open = FileMockFactory ( self , '<manifest   xmlns:android="http://schemas.android.com/apk/res/android"\n  package="com.google.fpl.libfplutil_test">\n  <uses-sdk android:minSdkVersion="1"/>\n  <application>\n    <activity android:name="android.app.NativeActivity">\n      <meta-data android:name="android.app.lib_name"\n                 android:value="test"/>\n      <intent-filter>\n       <action android:name="android.intent.action.MAIN"/>\n       <category android:name="android.intent.category.LAUNCHER"/>\n      </intent-filter>\n    </activity>\n  </application>\n</manifest>' ) #NEWLINE# build_environment = android . BuildEnvironment ( android . BuildEnvironment . build_defaults ( ) ) #NEWLINE# expected_logoutput = 'Random log output\nSome other log output\nAnother application log output.\nDisplayed com.google.fpl.libfplutil_test/android.app.NativeActivity\n' #NEWLINE# logoutput = ( expected_logoutput + 'Line noise\n' ) #NEWLINE# os . path . exists = ( lambda unused_filename : True ) #NEWLINE# build_environment . sdk_home = 'sdk_home' #NEWLINE# package = 'com.google.fpl.libfplutil_test' #NEWLINE# activity = 'android.app.NativeActivity' #NEWLINE# adb_path = build_environment . _find_binary ( android . BuildEnvironment . ADB ) #NEWLINE# run_command_mock = common_test . RunCommandMockList ( [ common_test . RunCommandMock ( self , args = ( '%s devices -l' % adb_path ) , stdout = 'List of devices attached\n123456\tdevice\tusb:2-3.4\tproduct:razor\tmodel:Nexus_7\tdevice:flo\n' ) , common_test . RunCommandMock ( self , args = ( '%s -s 123456 shell am force-stop %s' % ( adb_path , package ) ) ) , common_test . RunCommandMock ( self , args = ( '%s -s 123456 logcat -c' % adb_path ) ) , common_test . RunCommandMock ( self , args = ( '%s -s 123456 shell am start -n %s/%s' % ( adb_path , package , activity ) ) , stdout = '' ) ] ) #NEWLINE# build_environment . run_subprocess = run_command_mock #NEWLINE# subprocess . Popen = SubprocessMockStdOut ( self , args = [ adb_path , '-s' , '123456' , 'logcat' ] , stdout = logoutput ) #NEWLINE# self . assertEquals ( expected_logoutput , build_environment . run_android_apk ( adb_device = '123456' ) )