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

Side by Side Diff: content/browser/tracing/tracing_controller_browsertest.cc

Issue 139313005: Implement TracingController::GetMonitoringStatus (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/tracing/tracing_controller_impl.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "content/browser/tracing/tracing_controller_impl.h" 7 #include "content/browser/tracing/tracing_controller_impl.h"
8 #include "content/public/test/browser_test_utils.h" 8 #include "content/public/test/browser_test_utils.h"
9 #include "content/shell/browser/shell.h" 9 #include "content/shell/browser/shell.h"
10 #include "content/test/content_browser_test.h" 10 #include "content/test/content_browser_test.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 } 142 }
143 143
144 void TestEnableCaptureAndDisableMonitoring( 144 void TestEnableCaptureAndDisableMonitoring(
145 const base::FilePath& result_file_path) { 145 const base::FilePath& result_file_path) {
146 Navigate(shell()); 146 Navigate(shell());
147 147
148 TracingController* controller = TracingController::GetInstance(); 148 TracingController* controller = TracingController::GetInstance();
149 149
150 { 150 {
151 bool is_monitoring;
152 std::string category_filter;
153 TracingController::Options options;
154 controller->GetMonitoringStatus(&is_monitoring,
155 &category_filter,
156 &options);
157 EXPECT_FALSE(is_monitoring);
158 EXPECT_EQ("-*Debug,-*Test", category_filter);
159 EXPECT_FALSE(options & TracingController::ENABLE_SYSTRACE);
160 EXPECT_FALSE(options & TracingController::RECORD_CONTINUOUSLY);
161 EXPECT_FALSE(options & TracingController::ENABLE_SAMPLING);
162 }
163
164 {
151 base::RunLoop run_loop; 165 base::RunLoop run_loop;
152 TracingController::EnableMonitoringDoneCallback callback = 166 TracingController::EnableMonitoringDoneCallback callback =
153 base::Bind(&TracingControllerTest::EnableMonitoringDoneCallbackTest, 167 base::Bind(&TracingControllerTest::EnableMonitoringDoneCallbackTest,
154 base::Unretained(this), 168 base::Unretained(this),
155 run_loop.QuitClosure()); 169 run_loop.QuitClosure());
156 bool result = controller->EnableMonitoring( 170 bool result = controller->EnableMonitoring(
157 "", TracingController::ENABLE_SAMPLING, callback); 171 "*", TracingController::ENABLE_SAMPLING, callback);
158 ASSERT_TRUE(result); 172 ASSERT_TRUE(result);
159 run_loop.Run(); 173 run_loop.Run();
160 EXPECT_EQ(enable_monitoring_done_callback_count(), 1); 174 EXPECT_EQ(enable_monitoring_done_callback_count(), 1);
161 } 175 }
162 176
163 { 177 {
178 bool is_monitoring;
179 std::string category_filter;
180 TracingController::Options options;
181 controller->GetMonitoringStatus(&is_monitoring,
182 &category_filter,
183 &options);
184 EXPECT_TRUE(is_monitoring);
185 EXPECT_EQ("*", category_filter);
186 EXPECT_FALSE(options & TracingController::ENABLE_SYSTRACE);
187 EXPECT_FALSE(options & TracingController::RECORD_CONTINUOUSLY);
188 EXPECT_TRUE(options & TracingController::ENABLE_SAMPLING);
189 }
190
191 {
164 base::RunLoop run_loop; 192 base::RunLoop run_loop;
165 TracingController::TracingFileResultCallback callback = 193 TracingController::TracingFileResultCallback callback =
166 base::Bind(&TracingControllerTest:: 194 base::Bind(&TracingControllerTest::
167 CaptureMonitoringSnapshotDoneCallbackTest, 195 CaptureMonitoringSnapshotDoneCallbackTest,
168 base::Unretained(this), 196 base::Unretained(this),
169 run_loop.QuitClosure()); 197 run_loop.QuitClosure());
170 ASSERT_TRUE(controller->CaptureMonitoringSnapshot(result_file_path, 198 ASSERT_TRUE(controller->CaptureMonitoringSnapshot(result_file_path,
171 callback)); 199 callback));
172 run_loop.Run(); 200 run_loop.Run();
173 EXPECT_EQ(capture_monitoring_snapshot_done_callback_count(), 1); 201 EXPECT_EQ(capture_monitoring_snapshot_done_callback_count(), 1);
174 } 202 }
175 203
176 { 204 {
177 base::RunLoop run_loop; 205 base::RunLoop run_loop;
178 TracingController::DisableMonitoringDoneCallback callback = 206 TracingController::DisableMonitoringDoneCallback callback =
179 base::Bind(&TracingControllerTest::DisableMonitoringDoneCallbackTest, 207 base::Bind(&TracingControllerTest::DisableMonitoringDoneCallbackTest,
180 base::Unretained(this), 208 base::Unretained(this),
181 run_loop.QuitClosure()); 209 run_loop.QuitClosure());
182 bool result = controller->DisableMonitoring(callback); 210 bool result = controller->DisableMonitoring(callback);
183 ASSERT_TRUE(result); 211 ASSERT_TRUE(result);
184 run_loop.Run(); 212 run_loop.Run();
185 EXPECT_EQ(disable_monitoring_done_callback_count(), 1); 213 EXPECT_EQ(disable_monitoring_done_callback_count(), 1);
186 } 214 }
215
216 {
217 bool is_monitoring;
218 std::string category_filter;
219 TracingController::Options options;
220 controller->GetMonitoringStatus(&is_monitoring,
221 &category_filter,
222 &options);
223 EXPECT_FALSE(is_monitoring);
224 EXPECT_EQ("", category_filter);
225 EXPECT_FALSE(options & TracingController::ENABLE_SYSTRACE);
226 EXPECT_FALSE(options & TracingController::RECORD_CONTINUOUSLY);
227 EXPECT_FALSE(options & TracingController::ENABLE_SAMPLING);
228 }
187 } 229 }
188 230
189 private: 231 private:
190 int get_categories_done_callback_count_; 232 int get_categories_done_callback_count_;
191 int enable_recording_done_callback_count_; 233 int enable_recording_done_callback_count_;
192 int disable_recording_done_callback_count_; 234 int disable_recording_done_callback_count_;
193 int enable_monitoring_done_callback_count_; 235 int enable_monitoring_done_callback_count_;
194 int disable_monitoring_done_callback_count_; 236 int disable_monitoring_done_callback_count_;
195 int capture_monitoring_snapshot_done_callback_count_; 237 int capture_monitoring_snapshot_done_callback_count_;
196 base::FilePath last_actual_recording_file_path_; 238 base::FilePath last_actual_recording_file_path_;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 EXPECT_EQ(file_path.value(), last_actual_monitoring_file_path().value()); 292 EXPECT_EQ(file_path.value(), last_actual_monitoring_file_path().value());
251 } 293 }
252 294
253 IN_PROC_BROWSER_TEST_F( 295 IN_PROC_BROWSER_TEST_F(
254 TracingControllerTest, 296 TracingControllerTest,
255 EnableCaptureAndDisableMonitoringWithEmptyFileAndNullCallback) { 297 EnableCaptureAndDisableMonitoringWithEmptyFileAndNullCallback) {
256 Navigate(shell()); 298 Navigate(shell());
257 299
258 TracingController* controller = TracingController::GetInstance(); 300 TracingController* controller = TracingController::GetInstance();
259 EXPECT_TRUE(controller->EnableMonitoring( 301 EXPECT_TRUE(controller->EnableMonitoring(
260 "", TracingController::ENABLE_SAMPLING, 302 "*", TracingController::ENABLE_SAMPLING,
261 TracingController::EnableMonitoringDoneCallback())); 303 TracingController::EnableMonitoringDoneCallback()));
262 controller->CaptureMonitoringSnapshot( 304 controller->CaptureMonitoringSnapshot(
263 base::FilePath(), TracingController::TracingFileResultCallback()); 305 base::FilePath(), TracingController::TracingFileResultCallback());
264 base::RunLoop().RunUntilIdle(); 306 base::RunLoop().RunUntilIdle();
265 EXPECT_TRUE(controller->DisableMonitoring( 307 EXPECT_TRUE(controller->DisableMonitoring(
266 TracingController::DisableMonitoringDoneCallback())); 308 TracingController::DisableMonitoringDoneCallback()));
267 base::RunLoop().RunUntilIdle(); 309 base::RunLoop().RunUntilIdle();
268 } 310 }
269 311
270 } // namespace content 312 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/tracing/tracing_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698