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

Unified Diff: build/android/devil/android/tools/script_common_test.py

Issue 1522313002: [Android] Move screenshot and video_recorder into devil. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix video_recorder timing Created 5 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 side-by-side diff with in-line comments
Download patch
Index: build/android/devil/android/tools/script_common_test.py
diff --git a/build/android/devil/android/tools/script_common_test.py b/build/android/devil/android/tools/script_common_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..5f4ef5f27b2c0f2ca090ef7b1fdfae37cd9ae1a0
--- /dev/null
+++ b/build/android/devil/android/tools/script_common_test.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# Copyright 2015 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 sys
+import unittest
+
+from devil import devil_env
+from devil.android import device_errors
+from devil.android import device_utils
+from devil.android.tools import script_common
+
+with devil_env.SysPath(devil_env.config.LocalPath('pymock')):
+ import mock # pylint: disable=import-error
+
+
+class ScriptCommonTest(unittest.TestCase):
+
+ def testGetDevices_noSpecs(self):
+ devices = [
+ device_utils.DeviceUtils('123'),
+ device_utils.DeviceUtils('456'),
+ ]
+ with mock.patch('devil.android.device_utils.DeviceUtils.HealthyDevices',
+ return_value=devices):
+ self.assertEquals(
+ devices,
+ script_common.GetDevices(None, None))
+
+ def testGetDevices_withDevices(self):
+ devices = [
+ device_utils.DeviceUtils('123'),
+ device_utils.DeviceUtils('456'),
+ ]
+ with mock.patch('devil.android.device_utils.DeviceUtils.HealthyDevices',
+ return_value=devices):
+ self.assertEquals(
+ [device_utils.DeviceUtils('456')],
+ script_common.GetDevices(['456'], None))
+
+ def testGetDevices_missingDevice(self):
+ with mock.patch('devil.android.device_utils.DeviceUtils.HealthyDevices',
+ return_value=[device_utils.DeviceUtils('123')]):
+ with self.assertRaises(device_errors.DeviceUnreachableError):
+ script_common.GetDevices(['456'], None)
+
+ def testGetDevices_noDevices(self):
+ with mock.patch('devil.android.device_utils.DeviceUtils.HealthyDevices',
+ return_value=[]):
+ with self.assertRaises(device_errors.NoDevicesError):
+ script_common.GetDevices(None, None)
+
+
+if __name__ == '__main__':
+ sys.exit(unittest.main())
+
« no previous file with comments | « build/android/devil/android/tools/script_common.py ('k') | build/android/devil/android/tools/video_recorder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698