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

Side by Side Diff: tools/profile_chrome/trace_packager_unittest.py

Issue 402803005: Move adb_profile_chrome to profile_chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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/profile_chrome/trace_packager.py ('k') | tools/profile_chrome/ui.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 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 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 from adb_profile_chrome import trace_packager
6
7 import json 5 import json
8 import tempfile 6 import tempfile
9 import unittest 7 import unittest
10 8
9 from profile_chrome import trace_packager
10
11 11
12 class TracePackagerTest(unittest.TestCase): 12 class TracePackagerTest(unittest.TestCase):
13 def testJsonTraceMerging(self): 13 def testJsonTraceMerging(self):
14 t1 = {'traceEvents': [{'ts': 123, 'ph': 'b'}]} 14 t1 = {'traceEvents': [{'ts': 123, 'ph': 'b'}]}
15 t2 = {'traceEvents': [], 'stackFrames': ['blah']} 15 t2 = {'traceEvents': [], 'stackFrames': ['blah']}
16 16
17 # Both trace files will be merged to a third file and will get deleted in 17 # Both trace files will be merged to a third file and will get deleted in
18 # the process, so there's no need for NamedTemporaryFile to do the 18 # the process, so there's no need for NamedTemporaryFile to do the
19 # deletion. 19 # deletion.
20 with tempfile.NamedTemporaryFile(delete=False) as f1, \ 20 with tempfile.NamedTemporaryFile(delete=False) as f1, \
21 tempfile.NamedTemporaryFile(delete=False) as f2: 21 tempfile.NamedTemporaryFile(delete=False) as f2:
22 f1.write(json.dumps(t1)) 22 f1.write(json.dumps(t1))
23 f2.write(json.dumps(t2)) 23 f2.write(json.dumps(t2))
24 f1.flush() 24 f1.flush()
25 f2.flush() 25 f2.flush()
26 26
27 with tempfile.NamedTemporaryFile() as output: 27 with tempfile.NamedTemporaryFile() as output:
28 trace_packager.PackageTraces([f1.name, f2.name], 28 trace_packager.PackageTraces([f1.name, f2.name],
29 output.name, 29 output.name,
30 compress=False, 30 compress=False,
31 write_json=True) 31 write_json=True)
32 with open(output.name) as output: 32 with open(output.name) as output:
33 output = json.load(output) 33 output = json.load(output)
34 self.assertEquals(output['traceEvents'], t1['traceEvents']) 34 self.assertEquals(output['traceEvents'], t1['traceEvents'])
35 self.assertEquals(output['stackFrames'], t2['stackFrames']) 35 self.assertEquals(output['stackFrames'], t2['stackFrames'])
OLDNEW
« no previous file with comments | « tools/profile_chrome/trace_packager.py ('k') | tools/profile_chrome/ui.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698