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

Unified Diff: tools/telemetry/telemetry/internal/backends/android_app_backend_unittest.py

Issue 1606243002: [Telemetry] Small fixes in android_app_backend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add unittest Created 4 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/internal/backends/android_app_backend.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/internal/backends/android_app_backend_unittest.py
diff --git a/tools/telemetry/telemetry/internal/backends/android_app_backend_unittest.py b/tools/telemetry/telemetry/internal/backends/android_app_backend_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..8140e894c1d6c151709b42fe29c3494399da6f23
--- /dev/null
+++ b/tools/telemetry/telemetry/internal/backends/android_app_backend_unittest.py
@@ -0,0 +1,38 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+import collections
+import mock
+import unittest
+
+from telemetry.internal.backends import android_app_backend
+from devil.android.sdk import intent as intent_module
+
+
+_FakeAndroidProcess = collections.namedtuple(
+ 'AndroidProcess', ['app_backend', 'pid', 'name'])
+
+
+class AndroidAppBackendUnittest(unittest.TestCase):
+
+ def setUp(self):
+ self.platform_backend = mock.Mock()
+ self.start_intent = intent_module.Intent(
+ package='com.example.my_app',
+ activity='com.example.my_app.LaunchMyApp')
+ self.app_backend = android_app_backend.AndroidAppBackend(
+ self.platform_backend, self.start_intent)
+
+ @mock.patch('telemetry.internal.backends.android_app_backend'
+ '.android_process.AndroidProcess', _FakeAndroidProcess)
+ def testGetProcesses(self):
+ # Only processes belonging to 'com.example.my_app' should match.
+ self.platform_backend.GetPsOutput.return_value = [
+ ['1111', 'com.example.my_app'],
+ ['2222', 'com.example.my_appointments_helper'],
+ ['3333', 'com.example.my_app:service'],
+ ['4444', 'com.example.some_other_app'],
+ ['5555', 'com_example_my_app'],
+ ]
+ process_pids = set(p.pid for p in self.app_backend.GetProcesses())
+ self.assertEquals(process_pids, set(['1111', '3333']))
« no previous file with comments | « tools/telemetry/telemetry/internal/backends/android_app_backend.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698