Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | #!/usr/bin/env python |
michael@0 | 2 | |
michael@0 | 3 | import mozdevice |
michael@0 | 4 | import mozlog |
michael@0 | 5 | import unittest |
michael@0 | 6 | from sut import MockAgent |
michael@0 | 7 | |
michael@0 | 8 | |
michael@0 | 9 | class TestLogCat(unittest.TestCase): |
michael@0 | 10 | """ Class to test methods assosiated with logcat """ |
michael@0 | 11 | |
michael@0 | 12 | def test_getLogcat(self): |
michael@0 | 13 | |
michael@0 | 14 | logcat_output = ("07-17 00:51:10.377 I/SUTAgentAndroid( 2933): onCreate\n\r" |
michael@0 | 15 | "07-17 00:51:10.457 D/dalvikvm( 2933): GC_CONCURRENT freed 351K, 17% free 2523K/3008K, paused 5ms+2ms, total 38ms\n\r" |
michael@0 | 16 | "07-17 00:51:10.497 I/SUTAgentAndroid( 2933): Caught exception creating file in /data/local/tmp: open failed: EACCES (Permission denied)\n\r" |
michael@0 | 17 | "07-17 00:51:10.507 E/SUTAgentAndroid( 2933): ERROR: Cannot access world writeable test root\n\r" |
michael@0 | 18 | "07-17 00:51:10.547 D/GeckoHealthRec( 3253): Initializing profile cache.\n\r" |
michael@0 | 19 | "07-17 00:51:10.607 D/GeckoHealthRec( 3253): Looking for /data/data/org.mozilla.fennec/files/mozilla/c09kfhne.default/times.json\n\r" |
michael@0 | 20 | "07-17 00:51:10.637 D/GeckoHealthRec( 3253): Using times.json for profile creation time.\n\r" |
michael@0 | 21 | "07-17 00:51:10.707 D/GeckoHealthRec( 3253): Incorporating environment: times.json profile creation = 1374026758604\n\r" |
michael@0 | 22 | "07-17 00:51:10.507 D/GeckoHealthRec( 3253): Requested prefs.\n\r" |
michael@0 | 23 | "07-17 06:50:54.907 I/SUTAgentAndroid( 3876): \n\r" |
michael@0 | 24 | "07-17 06:50:54.907 I/SUTAgentAndroid( 3876): Total Private Dirty Memory 3176 kb\n\r" |
michael@0 | 25 | "07-17 06:50:54.907 I/SUTAgentAndroid( 3876): Total Proportional Set Size Memory 5679 kb\n\r" |
michael@0 | 26 | "07-17 06:50:54.907 I/SUTAgentAndroid( 3876): Total Shared Dirty Memory 9216 kb\n\r" |
michael@0 | 27 | "07-17 06:55:21.627 I/SUTAgentAndroid( 3876): 127.0.0.1 : execsu /system/bin/logcat -v time -d dalvikvm:I " |
michael@0 | 28 | "ConnectivityService:S WifiMonitor:S WifiStateTracker:S wpa_supplicant:S NetworkStateTracker:S\n\r" |
michael@0 | 29 | "07-17 06:55:21.827 I/dalvikvm-heap( 3876): Grow heap (frag case) to 3.019MB for 102496-byte allocation\n\r" |
michael@0 | 30 | "return code [0]") |
michael@0 | 31 | |
michael@0 | 32 | inp = ("execsu /system/bin/logcat -v time -d " |
michael@0 | 33 | "dalvikvm:I ConnectivityService:S WifiMonitor:S " |
michael@0 | 34 | "WifiStateTracker:S wpa_supplicant:S NetworkStateTracker:S") |
michael@0 | 35 | |
michael@0 | 36 | commands = [(inp, logcat_output)] |
michael@0 | 37 | m = MockAgent(self, commands=commands) |
michael@0 | 38 | d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG) |
michael@0 | 39 | self.assertEqual(logcat_output[:-17].split('\r'), d.getLogcat()) |
michael@0 | 40 | |
michael@0 | 41 | def test_recordLogcat(self): |
michael@0 | 42 | |
michael@0 | 43 | commands = [("execsu /system/bin/logcat -c", "return code [0]")] |
michael@0 | 44 | |
michael@0 | 45 | m = MockAgent(self, commands=commands) |
michael@0 | 46 | d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG) |
michael@0 | 47 | # No error raised means success |
michael@0 | 48 | self.assertEqual(None, d.recordLogcat()) |
michael@0 | 49 | |
michael@0 | 50 | if __name__ == '__main__': |
michael@0 | 51 | unittest.main() |