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.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 void ExecuteJavascriptOnCurrentTab() { | 32 void ExecuteJavascriptOnCurrentTab() { |
33 content::RenderViewHost* rvh = browser()->tab_strip_model()-> | 33 content::RenderViewHost* rvh = browser()->tab_strip_model()-> |
34 GetActiveWebContents()->GetRenderViewHost(); | 34 GetActiveWebContents()->GetRenderViewHost(); |
35 ASSERT_TRUE(rvh); | 35 ASSERT_TRUE(rvh); |
36 ASSERT_TRUE(content::ExecuteScript(rvh, ";")); | 36 ASSERT_TRUE(content::ExecuteScript(rvh, ";")); |
37 } | 37 } |
38 }; | 38 }; |
39 | 39 |
40 void AddEvents(int num) { | 40 void AddEvents(int num) { |
41 for (int i = 0; i < num; ++i) | 41 for (int i = 0; i < num; ++i) |
42 TRACE_EVENT_INSTANT0(g_category, g_event); | 42 TRACE_EVENT_INSTANT0(g_category, g_event, TRACE_EVENT_SCOPE_THREAD); |
43 } | 43 } |
44 | 44 |
45 IN_PROC_BROWSER_TEST_F(TracingBrowserTest, BeginTracingWithWatch) { | 45 IN_PROC_BROWSER_TEST_F(TracingBrowserTest, BeginTracingWithWatch) { |
46 base::TimeDelta no_timeout; | 46 base::TimeDelta no_timeout; |
47 base::TimeDelta short_timeout = base::TimeDelta::FromMilliseconds(5); | 47 base::TimeDelta short_timeout = base::TimeDelta::FromMilliseconds(5); |
48 std::string json_events; | 48 std::string json_events; |
49 | 49 |
50 // One event before wait. | 50 // One event before wait. |
51 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 1)); | 51 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 1)); |
52 AddEvents(1); | 52 AddEvents(1); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 96 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
97 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); | 97 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); |
98 ui_test_utils::NavigateToURLWithDisposition(browser(), url2, | 98 ui_test_utils::NavigateToURLWithDisposition(browser(), url2, |
99 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 99 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
100 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); | 100 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); |
101 EXPECT_TRUE(WaitForWatchEvent(no_timeout)); | 101 EXPECT_TRUE(WaitForWatchEvent(no_timeout)); |
102 ASSERT_TRUE(EndTracing(&json_events)); | 102 ASSERT_TRUE(EndTracing(&json_events)); |
103 } | 103 } |
104 | 104 |
105 } // namespace | 105 } // namespace |
OLD | NEW |