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

Side by Side Diff: tools/memory_inspector/tests/mock_adb/mock_adb.py

Issue 167223002: Fix directory layout for tools/memory_inspector tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/memory_inspector/tests/mock_adb/adb ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import json
6 import os
7 import tempfile
8
9
10 class MockAdb(object):
11 """Simple and effective mock for Android adb.
12
13 This module is meant to be used in integration tests in conjunction with the
14 other script named 'adb' living in the same directory.
15 The purpose of this class is preparing a dictionary of mocked responses to adb
16 commands. The dictionary is stored into a json file and read by the mock 'adb'
17 script. The path of the json dict is held in the MOCK_ADB_CFG env var.
18 """
19
20 def __init__(self):
21 self._responses = {} # Maps expected_cmd (str) -> prepared_response (str).
22 self._cfg_file = None
23
24 def Start(self):
25 (fd_num, self._cfg_file) = tempfile.mkstemp()
26 with os.fdopen(fd_num, 'w') as f:
27 json.dump(self._responses, f)
28 f.close()
29 os.environ['MOCK_ADB_CFG'] = self._cfg_file
30
31 def Stop(self):
32 assert(self._cfg_file), 'Stop called before Start.'
33 os.unlink(self._cfg_file)
34
35 def PrepareResponse(self, cmd, response):
36 self._responses[cmd] = response
OLDNEW
« 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