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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 using base::trace_event::MemoryDumpManager; | 27 using base::trace_event::MemoryDumpManager; |
28 using base::trace_event::MemoryDumpType; | 28 using base::trace_event::MemoryDumpType; |
29 using tracing::BeginTracingWithTraceConfig; | 29 using tracing::BeginTracingWithTraceConfig; |
30 using tracing::EndTracing; | 30 using tracing::EndTracing; |
31 | 31 |
32 const char g_category[] = "test_tracing"; | |
33 const char g_event[] = "TheEvent"; | |
34 | |
35 class TracingBrowserTest : public InProcessBrowserTest { | 32 class TracingBrowserTest : public InProcessBrowserTest { |
36 protected: | 33 protected: |
37 // Execute some no-op javascript on the current tab - this triggers a trace | 34 // Execute some no-op javascript on the current tab - this triggers a trace |
38 // event in RenderFrameImpl::OnJavaScriptExecuteRequestForTests (from the | 35 // event in RenderFrameImpl::OnJavaScriptExecuteRequestForTests (from the |
39 // renderer process). | 36 // renderer process). |
40 void ExecuteJavascriptOnCurrentTab() { | 37 void ExecuteJavascriptOnCurrentTab() { |
41 content::RenderViewHost* rvh = browser()->tab_strip_model()-> | 38 content::RenderViewHost* rvh = browser()->tab_strip_model()-> |
42 GetActiveWebContents()->GetRenderViewHost(); | 39 GetActiveWebContents()->GetRenderViewHost(); |
43 ASSERT_TRUE(rvh); | 40 ASSERT_TRUE(rvh); |
44 ASSERT_TRUE(content::ExecuteScript(rvh, ";")); | 41 ASSERT_TRUE(content::ExecuteScript(rvh, ";")); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 std::string json_events; | 73 std::string json_events; |
77 ASSERT_TRUE(EndTracing(&json_events)); | 74 ASSERT_TRUE(EndTracing(&json_events)); |
78 | 75 |
79 // Expect the basic memory dumps to be present in the trace. | 76 // Expect the basic memory dumps to be present in the trace. |
80 EXPECT_NE(std::string::npos, json_events.find("process_totals")); | 77 EXPECT_NE(std::string::npos, json_events.find("process_totals")); |
81 EXPECT_NE(std::string::npos, json_events.find("v8")); | 78 EXPECT_NE(std::string::npos, json_events.find("v8")); |
82 EXPECT_NE(std::string::npos, json_events.find("blink_gc")); | 79 EXPECT_NE(std::string::npos, json_events.find("blink_gc")); |
83 } | 80 } |
84 }; | 81 }; |
85 | 82 |
86 void AddEvents(int num) { | |
87 for (int i = 0; i < num; ++i) | |
88 TRACE_EVENT_INSTANT0(g_category, g_event, TRACE_EVENT_SCOPE_THREAD); | |
89 } | |
90 | |
91 IN_PROC_BROWSER_TEST_F(TracingBrowserTest, TestMemoryInfra) { | 83 IN_PROC_BROWSER_TEST_F(TracingBrowserTest, TestMemoryInfra) { |
92 PerformDumpMemoryTestActions(base::trace_event::TraceConfig( | 84 PerformDumpMemoryTestActions(base::trace_event::TraceConfig( |
93 base::trace_event::TraceConfigMemoryTestUtil:: | 85 base::trace_event::TraceConfigMemoryTestUtil:: |
94 GetTraceConfig_PeriodicTriggers(250, 2000))); | 86 GetTraceConfig_PeriodicTriggers(250, 2000))); |
95 } | 87 } |
96 | 88 |
97 IN_PROC_BROWSER_TEST_F(TracingBrowserTest, TestBackgroundMemoryInfra) { | 89 IN_PROC_BROWSER_TEST_F(TracingBrowserTest, TestBackgroundMemoryInfra) { |
98 PerformDumpMemoryTestActions(base::trace_event::TraceConfig( | 90 PerformDumpMemoryTestActions(base::trace_event::TraceConfig( |
99 base::trace_event::TraceConfigMemoryTestUtil:: | 91 base::trace_event::TraceConfigMemoryTestUtil:: |
100 GetTraceConfig_BackgroundTrigger(200))); | 92 GetTraceConfig_BackgroundTrigger(200))); |
101 } | 93 } |
102 | 94 |
103 } // namespace | 95 } // namespace |
OLD | NEW |