Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: build/android/pylib/gtest/test_package_apk.py

Issue 788753002: [Android] Implement gtest and local in platform mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix findbugs + move log parsing up to GtestTestInstance Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Defines TestPackageApk to help run APK-based native tests.""" 5 """Defines TestPackageApk to help run APK-based native tests."""
6 # pylint: disable=W0212 6 # pylint: disable=W0212
7 7
8 import logging 8 import logging
9 import os 9 import os
10 import shlex 10 import shlex
11 import sys 11 import sys
12 import tempfile 12 import tempfile
13 import time 13 import time
14 14
15 from pylib import android_commands 15 from pylib import android_commands
16 from pylib import constants 16 from pylib import constants
17 from pylib import pexpect 17 from pylib import pexpect
18 from pylib.device import device_errors 18 from pylib.device import device_errors
19 from pylib.device import intent 19 from pylib.device import intent
20 from pylib.gtest import gtest_test_instance
20 from pylib.gtest.test_package import TestPackage 21 from pylib.gtest.test_package import TestPackage
21 22
22 23
23 class TestPackageApk(TestPackage): 24 class TestPackageApk(TestPackage):
24 """A helper class for running APK-based native tests.""" 25 """A helper class for running APK-based native tests."""
25 26
26 def __init__(self, suite_name): 27 def __init__(self, suite_name):
27 """ 28 """
28 Args: 29 Args:
29 suite_name: Name of the test suite (e.g. base_unittests). 30 suite_name: Name of the test suite (e.g. base_unittests).
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 self._ClearFifo(device) 105 self._ClearFifo(device)
105 self._StartActivity(device) 106 self._StartActivity(device)
106 # Wait for native test to complete. 107 # Wait for native test to complete.
107 p = self._WatchFifo(device, timeout=30 * self.tool.GetTimeoutScale()) 108 p = self._WatchFifo(device, timeout=30 * self.tool.GetTimeoutScale())
108 p.expect('<<ScopedMainEntryLogger') 109 p.expect('<<ScopedMainEntryLogger')
109 p.close() 110 p.close()
110 finally: 111 finally:
111 self.tool.CleanUpEnvironment() 112 self.tool.CleanUpEnvironment()
112 # We need to strip the trailing newline. 113 # We need to strip the trailing newline.
113 content = [line.rstrip() for line in p.before.splitlines()] 114 content = [line.rstrip() for line in p.before.splitlines()]
114 return self._ParseGTestListTests(content) 115 return gtest_test_instance.ParseGTestListTests(content)
115 116
116 #override 117 #override
117 def SpawnTestProcess(self, device): 118 def SpawnTestProcess(self, device):
118 try: 119 try:
119 self.tool.SetupEnvironment() 120 self.tool.SetupEnvironment()
120 self._ClearFifo(device) 121 self._ClearFifo(device)
121 self._StartActivity(device) 122 self._StartActivity(device)
122 finally: 123 finally:
123 self.tool.CleanUpEnvironment() 124 self.tool.CleanUpEnvironment()
124 logfile = android_commands.NewLineNormalizer(sys.stdout) 125 logfile = android_commands.NewLineNormalizer(sys.stdout)
125 return self._WatchFifo(device, timeout=10, logfile=logfile) 126 return self._WatchFifo(device, timeout=10, logfile=logfile)
126 127
127 #override 128 #override
128 def Install(self, device): 129 def Install(self, device):
129 self.tool.CopyFiles(device) 130 self.tool.CopyFiles(device)
130 device.Install(self.suite_path) 131 device.Install(self.suite_path)
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/test_package.py ('k') | build/android/pylib/gtest/test_package_exe.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698