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

Side by Side Diff: content/renderer/devtools/v8_sampling_profiler_browsertest.cc

Issue 1123783002: Add ExecuteJavaScriptForTest and make all tests use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "content/public/test/render_view_test.h" 8 #include "content/public/test/render_view_test.h"
9 #include "content/renderer/devtools/v8_sampling_profiler.h" 9 #include "content/renderer/devtools/v8_sampling_profiler.h"
10 10
(...skipping 12 matching lines...) Expand all
23 RenderViewTest::SetUp(); 23 RenderViewTest::SetUp();
24 sampling_profiler_.reset(new V8SamplingProfiler(true)); 24 sampling_profiler_.reset(new V8SamplingProfiler(true));
25 trace_buffer_.SetOutputCallback(json_output_.GetCallback()); 25 trace_buffer_.SetOutputCallback(json_output_.GetCallback());
26 } 26 }
27 27
28 void TearDown() override { 28 void TearDown() override {
29 sampling_profiler_.reset(); 29 sampling_profiler_.reset();
30 RenderViewTest::TearDown(); 30 RenderViewTest::TearDown();
31 } 31 }
32 32
33 void KickV8() { ExecuteJavaScript("1"); } 33 void KickV8() { ExecuteJavaScriptForTests("1"); }
34 34
35 void SyncFlush(TraceLog* trace_log) { 35 void SyncFlush(TraceLog* trace_log) {
36 base::WaitableEvent flush_complete_event(false, false); 36 base::WaitableEvent flush_complete_event(false, false);
37 trace_log->Flush( 37 trace_log->Flush(
38 base::Bind(&V8SamplingProfilerTest::OnTraceDataCollected, 38 base::Bind(&V8SamplingProfilerTest::OnTraceDataCollected,
39 base::Unretained(static_cast<V8SamplingProfilerTest*>(this)), 39 base::Unretained(static_cast<V8SamplingProfilerTest*>(this)),
40 base::Unretained(&flush_complete_event))); 40 base::Unretained(&flush_complete_event)));
41 base::RunLoop().RunUntilIdle(); 41 base::RunLoop().RunUntilIdle();
42 flush_complete_event.Wait(); 42 flush_complete_event.Wait();
43 } 43 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 TEST_F(V8SamplingProfilerTest, V8SamplingSamplesCollected) { 139 TEST_F(V8SamplingProfilerTest, V8SamplingSamplesCollected) {
140 CollectTrace(0, 1); 140 CollectTrace(0, 1);
141 int sample_events_count = CountEvents("V8Sample"); 141 int sample_events_count = CountEvents("V8Sample");
142 CHECK_LT(0, sample_events_count); 142 CHECK_LT(0, sample_events_count);
143 base::RunLoop().RunUntilIdle(); 143 base::RunLoop().RunUntilIdle();
144 } 144 }
145 145
146 } // namespace content 146 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/accessibility/renderer_accessibility_browsertest.cc ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698