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

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

Issue 1167163002: chrome: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added some missing message_loop.h includes. Created 5 years, 6 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
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | chrome/test/base/view_event_test_base.cc » ('j') | 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/message_loop/message_loop.h" 7 #include "base/location.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h"
9 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
10 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
13 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
14 #include "content/public/browser/render_view_host.h" 16 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
16 #include "content/public/test/browser_test_utils.h" 18 #include "content/public/test/browser_test_utils.h"
17 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
18 20
(...skipping 30 matching lines...) Expand all
49 std::string json_events; 51 std::string json_events;
50 52
51 // One event before wait. 53 // One event before wait.
52 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 1)); 54 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 1));
53 AddEvents(1); 55 AddEvents(1);
54 EXPECT_TRUE(WaitForWatchEvent(no_timeout)); 56 EXPECT_TRUE(WaitForWatchEvent(no_timeout));
55 ASSERT_TRUE(EndTracing(&json_events)); 57 ASSERT_TRUE(EndTracing(&json_events));
56 58
57 // One event after wait. 59 // One event after wait.
58 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 1)); 60 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 1));
59 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&AddEvents, 1)); 61 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
62 base::Bind(&AddEvents, 1));
60 EXPECT_TRUE(WaitForWatchEvent(no_timeout)); 63 EXPECT_TRUE(WaitForWatchEvent(no_timeout));
61 ASSERT_TRUE(EndTracing(&json_events)); 64 ASSERT_TRUE(EndTracing(&json_events));
62 65
63 // Not enough events timeout. 66 // Not enough events timeout.
64 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 2)); 67 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 2));
65 AddEvents(1); 68 AddEvents(1);
66 EXPECT_FALSE(WaitForWatchEvent(short_timeout)); 69 EXPECT_FALSE(WaitForWatchEvent(short_timeout));
67 ASSERT_TRUE(EndTracing(&json_events)); 70 ASSERT_TRUE(EndTracing(&json_events));
68 71
69 // Multi event before wait. 72 // Multi event before wait.
70 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 5)); 73 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 5));
71 AddEvents(5); 74 AddEvents(5);
72 EXPECT_TRUE(WaitForWatchEvent(no_timeout)); 75 EXPECT_TRUE(WaitForWatchEvent(no_timeout));
73 ASSERT_TRUE(EndTracing(&json_events)); 76 ASSERT_TRUE(EndTracing(&json_events));
74 77
75 // Multi event after wait. 78 // Multi event after wait.
76 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 5)); 79 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, g_event, 5));
77 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&AddEvents, 5)); 80 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
81 base::Bind(&AddEvents, 5));
78 EXPECT_TRUE(WaitForWatchEvent(no_timeout)); 82 EXPECT_TRUE(WaitForWatchEvent(no_timeout));
79 ASSERT_TRUE(EndTracing(&json_events)); 83 ASSERT_TRUE(EndTracing(&json_events));
80 84
81 // Child process events from same process. 85 // Child process events from same process.
82 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, 86 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category,
83 "OnJavaScriptExecuteRequestForTests", 2)); 87 "OnJavaScriptExecuteRequestForTests", 2));
84 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); 88 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab());
85 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); 89 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab());
86 EXPECT_TRUE(WaitForWatchEvent(no_timeout)); 90 EXPECT_TRUE(WaitForWatchEvent(no_timeout));
87 ASSERT_TRUE(EndTracing(&json_events)); 91 ASSERT_TRUE(EndTracing(&json_events));
88 92
89 // Child process events from different processes. 93 // Child process events from different processes.
90 GURL url1("chrome://tracing/"); 94 GURL url1("chrome://tracing/");
91 GURL url2("chrome://credits/"); 95 GURL url2("chrome://credits/");
92 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category, 96 ASSERT_TRUE(BeginTracingWithWatch(g_category, g_category,
93 "OnJavaScriptExecuteRequestForTests", 2)); 97 "OnJavaScriptExecuteRequestForTests", 2));
94 // Open two tabs to different URLs to encourage two separate renderer 98 // Open two tabs to different URLs to encourage two separate renderer
95 // processes. Each will fire an event that will be counted towards the total. 99 // processes. Each will fire an event that will be counted towards the total.
96 ui_test_utils::NavigateToURLWithDisposition(browser(), url1, 100 ui_test_utils::NavigateToURLWithDisposition(browser(), url1,
97 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 101 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
98 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); 102 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab());
99 ui_test_utils::NavigateToURLWithDisposition(browser(), url2, 103 ui_test_utils::NavigateToURLWithDisposition(browser(), url2,
100 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 104 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
101 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab()); 105 ASSERT_NO_FATAL_FAILURE(ExecuteJavascriptOnCurrentTab());
102 EXPECT_TRUE(WaitForWatchEvent(no_timeout)); 106 EXPECT_TRUE(WaitForWatchEvent(no_timeout));
103 ASSERT_TRUE(EndTracing(&json_events)); 107 ASSERT_TRUE(EndTracing(&json_events));
104 } 108 }
105 109
106 } // namespace 110 } // namespace
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | chrome/test/base/view_event_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698