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

Side by Side Diff: chrome/test/base/tracing_browsertest.cc

Issue 2572393002: Fix crashes in TracingBrowserTest.TestMemoryInfra (Closed)
Patch Set: . Created 4 years 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
« no previous file with comments | « chrome/test/base/tracing.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 void RequestGlobalDumpCallback(base::Closure quit_closure,
33 uint64_t,
34 bool success) {
35 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure);
36 ASSERT_TRUE(success);
37 }
38
39 void OnStartTracingDoneCallback(
40 base::trace_event::MemoryDumpLevelOfDetail explicit_dump_type,
41 base::Closure quit_closure) {
42 base::trace_event::MemoryDumpManager::GetInstance()->RequestGlobalDump(
43 MemoryDumpType::EXPLICITLY_TRIGGERED, explicit_dump_type,
44 Bind(&RequestGlobalDumpCallback, quit_closure));
45 }
46
32 class TracingBrowserTest : public InProcessBrowserTest { 47 class TracingBrowserTest : public InProcessBrowserTest {
33 protected: 48 protected:
34 // Execute some no-op javascript on the current tab - this triggers a trace 49 // Execute some no-op javascript on the current tab - this triggers a trace
35 // event in RenderFrameImpl::OnJavaScriptExecuteRequestForTests (from the 50 // event in RenderFrameImpl::OnJavaScriptExecuteRequestForTests (from the
36 // renderer process). 51 // renderer process).
37 void ExecuteJavascriptOnCurrentTab() { 52 void ExecuteJavascriptOnCurrentTab() {
38 content::RenderViewHost* rvh = browser()->tab_strip_model()-> 53 content::RenderViewHost* rvh = browser()->tab_strip_model()->
39 GetActiveWebContents()->GetRenderViewHost(); 54 GetActiveWebContents()->GetRenderViewHost();
40 ASSERT_TRUE(rvh); 55 ASSERT_TRUE(rvh);
41 ASSERT_TRUE(content::ExecuteScript(rvh, ";")); 56 ASSERT_TRUE(content::ExecuteScript(rvh, ";"));
42 } 57 }
43 58
44 void PerformDumpMemoryTestActions( 59 void PerformDumpMemoryTestActions(
45 const base::trace_event::TraceConfig& trace_config) { 60 const base::trace_event::TraceConfig& trace_config,
61 base::trace_event::MemoryDumpLevelOfDetail explicit_dump_type) {
46 GURL url1("about:blank"); 62 GURL url1("about:blank");
47 ui_test_utils::NavigateToURLWithDisposition( 63 ui_test_utils::NavigateToURLWithDisposition(
48 browser(), url1, WindowOpenDisposition::NEW_FOREGROUND_TAB, 64 browser(), url1, WindowOpenDisposition::NEW_FOREGROUND_TAB,
49 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 65 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
50 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); 66 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab());
51 67
52 // Begin tracing and watch for multiple periodic dump trace events. 68 // Begin tracing and trigger dump once start is broadcasted to all
53 std::string event_name = base::trace_event::MemoryDumpTypeToString( 69 // processes.
54 MemoryDumpType::PERIODIC_INTERVAL); 70 base::RunLoop run_loop;
55 ASSERT_TRUE(BeginTracingWithTraceConfig(trace_config)); 71 ASSERT_TRUE(BeginTracingWithTraceConfig(
72 trace_config, Bind(&OnStartTracingDoneCallback, explicit_dump_type,
73 run_loop.QuitClosure())));
56 74
57 // Create and destroy renderers while tracing is enabled. 75 // Create and destroy renderers while tracing is enabled.
58 GURL url2("chrome://credits"); 76 GURL url2("chrome://credits");
59 ui_test_utils::NavigateToURLWithDisposition( 77 ui_test_utils::NavigateToURLWithDisposition(
60 browser(), url2, WindowOpenDisposition::NEW_FOREGROUND_TAB, 78 browser(), url2, WindowOpenDisposition::NEW_FOREGROUND_TAB,
61 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 79 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
62 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); 80 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab());
63 81
64 // Close the current tab. 82 // Close the current tab.
65 browser()->tab_strip_model()->CloseSelectedTabs(); 83 browser()->tab_strip_model()->CloseSelectedTabs();
66 84
67 GURL url3("chrome://chrome-urls"); 85 GURL url3("chrome://chrome-urls");
68 ui_test_utils::NavigateToURLWithDisposition( 86 ui_test_utils::NavigateToURLWithDisposition(
69 browser(), url3, WindowOpenDisposition::CURRENT_TAB, 87 browser(), url3, WindowOpenDisposition::CURRENT_TAB,
70 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 88 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
71 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); 89 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab());
72 90
91 run_loop.Run();
73 std::string json_events; 92 std::string json_events;
74 ASSERT_TRUE(EndTracing(&json_events)); 93 ASSERT_TRUE(EndTracing(&json_events));
75 94
76 // Expect the basic memory dumps to be present in the trace. 95 // Expect the basic memory dumps to be present in the trace.
77 EXPECT_NE(std::string::npos, json_events.find("process_totals")); 96 EXPECT_NE(std::string::npos, json_events.find("process_totals"));
78 EXPECT_NE(std::string::npos, json_events.find("v8")); 97 EXPECT_NE(std::string::npos, json_events.find("v8"));
79 EXPECT_NE(std::string::npos, json_events.find("blink_gc")); 98 EXPECT_NE(std::string::npos, json_events.find("blink_gc"));
80 } 99 }
81 }; 100 };
82 101
83 // Flaky: http://crbug.com/658054 102 IN_PROC_BROWSER_TEST_F(TracingBrowserTest, TestMemoryInfra) {
84 IN_PROC_BROWSER_TEST_F(TracingBrowserTest, DISABLED_TestMemoryInfra) { 103 PerformDumpMemoryTestActions(
85 PerformDumpMemoryTestActions(base::trace_event::TraceConfig( 104 base::trace_event::TraceConfig(
86 base::trace_event::TraceConfigMemoryTestUtil:: 105 base::trace_event::TraceConfigMemoryTestUtil::
87 GetTraceConfig_PeriodicTriggers(250, 2000))); 106 GetTraceConfig_EmptyTriggers()),
107 base::trace_event::MemoryDumpLevelOfDetail::DETAILED);
88 } 108 }
89 109
90 // Flaky: http://crbug.com/658054 110 IN_PROC_BROWSER_TEST_F(TracingBrowserTest, TestBackgroundMemoryInfra) {
91 IN_PROC_BROWSER_TEST_F(TracingBrowserTest, DISABLED_TestBackgroundMemoryInfra) { 111 PerformDumpMemoryTestActions(
92 PerformDumpMemoryTestActions(base::trace_event::TraceConfig( 112 base::trace_event::TraceConfig(
93 base::trace_event::TraceConfigMemoryTestUtil:: 113 base::trace_event::TraceConfigMemoryTestUtil::
94 GetTraceConfig_BackgroundTrigger(200))); 114 GetTraceConfig_BackgroundTrigger(200)),
115 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND);
95 } 116 }
96 117
97 } // namespace 118 } // namespace
OLDNEW
« no previous file with comments | « chrome/test/base/tracing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698