Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / browser / tracing / tracing_controller_browsertest.cc
blobc88932e05973a2649f26f1d21f0bd405eecba292
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
3 // found in the LICENSE file.
5 #include "base/file_util.h"
6 #include "base/run_loop.h"
7 #include "content/browser/tracing/tracing_controller_impl.h"
8 #include "content/public/test/browser_test_utils.h"
9 #include "content/shell/browser/shell.h"
10 #include "content/test/content_browser_test.h"
11 #include "content/test/content_browser_test_utils.h"
13 namespace content {
15 class TracingControllerTest : public ContentBrowserTest {
16 public:
17 TracingControllerTest() {}
19 virtual void SetUp() OVERRIDE {
20 get_categories_done_callback_count_ = 0;
21 enable_recording_done_callback_count_ = 0;
22 disable_recording_done_callback_count_ = 0;
23 ContentBrowserTest::SetUp();
26 virtual void TearDown() OVERRIDE {
27 ContentBrowserTest::TearDown();
30 void Navigate(Shell* shell) {
31 NavigateToURL(shell, GetTestUrl("", "title.html"));
34 void GetCategoriesDoneCallbackTest(base::Closure quit_callback,
35 const std::set<std::string>& categories) {
36 get_categories_done_callback_count_++;
37 EXPECT_TRUE(categories.size() > 0);
38 quit_callback.Run();
41 void EnableRecordingDoneCallbackTest(base::Closure quit_callback) {
42 enable_recording_done_callback_count_++;
43 quit_callback.Run();
46 void DisableRecordingDoneCallbackTest(base::Closure quit_callback,
47 scoped_ptr<base::FilePath> file_path) {
48 disable_recording_done_callback_count_++;
49 EXPECT_TRUE(PathExists(*file_path));
50 quit_callback.Run();
53 int get_categories_done_callback_count() const {
54 return get_categories_done_callback_count_;
57 int enable_recording_done_callback_count() const {
58 return enable_recording_done_callback_count_;
61 int disable_recording_done_callback_count() const {
62 return disable_recording_done_callback_count_;
65 private:
66 int get_categories_done_callback_count_;
67 int enable_recording_done_callback_count_;
68 int disable_recording_done_callback_count_;
71 IN_PROC_BROWSER_TEST_F(TracingControllerTest, GetCategories) {
72 Navigate(shell());
74 TracingController* controller = TracingController::GetInstance();
76 base::RunLoop run_loop;
77 TracingController::GetCategoriesDoneCallback callback =
78 base::Bind(&TracingControllerTest::GetCategoriesDoneCallbackTest,
79 base::Unretained(this),
80 run_loop.QuitClosure());
81 controller->GetCategories(callback);
82 run_loop.Run();
83 EXPECT_EQ(get_categories_done_callback_count(), 1);
86 IN_PROC_BROWSER_TEST_F(TracingControllerTest, EnableAndDisableRecording) {
87 Navigate(shell());
89 TracingController* controller = TracingController::GetInstance();
92 base::RunLoop run_loop;
93 TracingController::EnableRecordingDoneCallback callback =
94 base::Bind(&TracingControllerTest::EnableRecordingDoneCallbackTest,
95 base::Unretained(this),
96 run_loop.QuitClosure());
97 controller->EnableRecording(base::debug::CategoryFilter("*"),
98 TracingController::Options(), callback);
99 run_loop.Run();
100 EXPECT_EQ(enable_recording_done_callback_count(), 1);
104 base::RunLoop run_loop;
105 TracingController::TracingFileResultCallback callback =
106 base::Bind(&TracingControllerTest::DisableRecordingDoneCallbackTest,
107 base::Unretained(this),
108 run_loop.QuitClosure());
109 controller->DisableRecording(callback);
110 run_loop.Run();
111 EXPECT_EQ(disable_recording_done_callback_count(), 1);
115 } // namespace content