OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/test/base/tracing.h" | 5 #include "chrome/test/base/tracing.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "chrome/browser/ui/browser_tabstrip.h" | 10 #include "chrome/browser/ui/browser_tabstrip.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 const char* g_event = "TheEvent"; | 25 const char* g_event = "TheEvent"; |
26 | 26 |
27 class TracingBrowserTest : public InProcessBrowserTest { | 27 class TracingBrowserTest : public InProcessBrowserTest { |
28 protected: | 28 protected: |
29 // Execute some no-op javascript on the current tab - this triggers a trace | 29 // Execute some no-op javascript on the current tab - this triggers a trace |
30 // event in RenderViewImpl::OnScriptEvalRequest (from the renderer process). | 30 // event in RenderViewImpl::OnScriptEvalRequest (from the renderer process). |
31 void ExecuteJavascriptOnCurrentTab() { | 31 void ExecuteJavascriptOnCurrentTab() { |
32 content::RenderViewHost* rvh = | 32 content::RenderViewHost* rvh = |
33 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); | 33 chrome::GetActiveWebContents(browser())->GetRenderViewHost(); |
34 ASSERT_TRUE(rvh); | 34 ASSERT_TRUE(rvh); |
35 ASSERT_TRUE(content::ExecuteJavaScript(rvh, "", ";")); | 35 ASSERT_TRUE(content::ExecuteScript(rvh, ";")); |
36 } | 36 } |
37 }; | 37 }; |
38 | 38 |
39 void AddEvents(int num) { | 39 void AddEvents(int num) { |
40 for (int i = 0; i < num; ++i) | 40 for (int i = 0; i < num; ++i) |
41 TRACE_EVENT_INSTANT0(g_category, g_event); | 41 TRACE_EVENT_INSTANT0(g_category, g_event); |
42 } | 42 } |
43 | 43 |
44 IN_PROC_BROWSER_TEST_F(TracingBrowserTest, BeginTracingWithWatch) { | 44 IN_PROC_BROWSER_TEST_F(TracingBrowserTest, BeginTracingWithWatch) { |
45 base::TimeDelta no_timeout; | 45 base::TimeDelta no_timeout; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 95 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
96 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); | 96 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); |
97 ui_test_utils::NavigateToURLWithDisposition(browser(), url2, | 97 ui_test_utils::NavigateToURLWithDisposition(browser(), url2, |
98 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 98 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
99 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); | 99 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); |
100 EXPECT_TRUE(WaitForWatchEvent(no_timeout)); | 100 EXPECT_TRUE(WaitForWatchEvent(no_timeout)); |
101 ASSERT_TRUE(EndTracing(&json_events)); | 101 ASSERT_TRUE(EndTracing(&json_events)); |
102 } | 102 } |
103 | 103 |
104 } // namespace | 104 } // namespace |
OLD | NEW |