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

Unified Diff: tools/memory_inspector/tests/mock_adb/mock_adb.py

Issue 158993002: Add Android-backend to the memory_inspector (prerequisites). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update ps_ext prebuilt sha1 Created 6 years, 10 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/memory_inspector/tests/mock_adb/adb ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/memory_inspector/tests/mock_adb/mock_adb.py
diff --git a/tools/memory_inspector/tests/mock_adb/mock_adb.py b/tools/memory_inspector/tests/mock_adb/mock_adb.py
new file mode 100644
index 0000000000000000000000000000000000000000..c514b0f53a3848ab36fdddeef0498cfe8e97b698
--- /dev/null
+++ b/tools/memory_inspector/tests/mock_adb/mock_adb.py
@@ -0,0 +1,36 @@
+# Copyright 2014 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 json
+import os
+import tempfile
+
+
+class MockAdb(object):
+ """Simple and effective mock for Android adb.
+
+ This module is meant to be used in integration tests in conjunction with the
+ other script named 'adb' living in the same directory.
+ The purpose of this class is preparing a dictionary of mocked responses to adb
+ commands. The dictionary is stored into a json file and read by the mock 'adb'
+ script. The path of the json dict is held in the MOCK_ADB_CFG env var.
+ """
+
+ def __init__(self):
+ self._responses = {} # Maps expected_cmd (str) -> prepared_response (str).
+ self._cfg_file = None
+
+ def Start(self):
+ (fd_num, self._cfg_file) = tempfile.mkstemp()
+ with os.fdopen(fd_num, 'w') as f:
+ json.dump(self._responses, f)
+ f.close()
+ os.environ['MOCK_ADB_CFG'] = self._cfg_file
+
+ def Stop(self):
+ assert(self._cfg_file), 'Stop called before Start.'
+ os.unlink(self._cfg_file)
+
+ def PrepareResponse(self, cmd, response):
+ self._responses[cmd] = response
« no previous file with comments | « tools/memory_inspector/tests/mock_adb/adb ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698