OLD | NEW |
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 "chrome/browser/extensions/error_console/error_console.h" | 5 #include "chrome/browser/extensions/error_console/error_console.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
14 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
| 15 #include "content/public/test/test_browser_thread_bundle.h" |
15 #include "extensions/browser/extension_error.h" | 16 #include "extensions/browser/extension_error.h" |
16 #include "extensions/common/constants.h" | 17 #include "extensions/common/constants.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 using base::string16; | 20 using base::string16; |
20 using base::UTF8ToUTF16; | 21 using base::UTF8ToUTF16; |
21 | 22 |
22 namespace extensions { | 23 namespace extensions { |
23 | 24 |
24 namespace { | 25 namespace { |
(...skipping 23 matching lines...) Expand all Loading... |
48 UTF8ToUTF16("source"), | 49 UTF8ToUTF16("source"), |
49 message, | 50 message, |
50 logging::LOG_INFO, | 51 logging::LOG_INFO, |
51 CreateErrorDetails(extension_id))); | 52 CreateErrorDetails(extension_id))); |
52 } | 53 } |
53 | 54 |
54 } // namespace | 55 } // namespace |
55 | 56 |
56 class ErrorConsoleUnitTest : public testing::Test { | 57 class ErrorConsoleUnitTest : public testing::Test { |
57 public: | 58 public: |
58 ErrorConsoleUnitTest() : | 59 ErrorConsoleUnitTest() |
59 profile_(new TestingProfile), | 60 : error_console_(ErrorConsole::Get(&profile_)) { |
60 error_console_(ErrorConsole::Get(profile_.get())) { | |
61 } | 61 } |
62 virtual ~ErrorConsoleUnitTest() { } | 62 virtual ~ErrorConsoleUnitTest() { } |
63 | 63 |
64 protected: | 64 protected: |
65 scoped_ptr<TestingProfile> profile_; | 65 content::TestBrowserThreadBundle thread_bundle_; |
| 66 TestingProfile profile_; |
66 ErrorConsole* error_console_; | 67 ErrorConsole* error_console_; |
67 }; | 68 }; |
68 | 69 |
69 // Test adding errors, and removing them by reference, by incognito status, | 70 // Test adding errors, and removing them by reference, by incognito status, |
70 // and in bulk. | 71 // and in bulk. |
71 TEST_F(ErrorConsoleUnitTest, AddAndRemoveErrors) { | 72 TEST_F(ErrorConsoleUnitTest, AddAndRemoveErrors) { |
72 ASSERT_EQ(0u, error_console_->errors().size()); | 73 ASSERT_EQ(0u, error_console_->errors().size()); |
73 | 74 |
74 const size_t kNumTotalErrors = 6; | 75 const size_t kNumTotalErrors = 6; |
75 const size_t kNumNonIncognitoErrors = 3; | 76 const size_t kNumNonIncognitoErrors = 3; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // We should have popped off errors in the order they arrived, so the | 145 // We should have popped off errors in the order they arrived, so the |
145 // first stored error should be the 6th reported (zero-based)... | 146 // first stored error should be the 6th reported (zero-based)... |
146 ASSERT_EQ(errors.front()->message(), | 147 ASSERT_EQ(errors.front()->message(), |
147 base::UintToString16(kNumExtraErrors)); | 148 base::UintToString16(kNumExtraErrors)); |
148 // ..and the last stored should be the 105th reported. | 149 // ..and the last stored should be the 105th reported. |
149 ASSERT_EQ(errors.back()->message(), | 150 ASSERT_EQ(errors.back()->message(), |
150 base::UintToString16(kMaxErrorsPerExtension + kNumExtraErrors - 1)); | 151 base::UintToString16(kMaxErrorsPerExtension + kNumExtraErrors - 1)); |
151 } | 152 } |
152 | 153 |
153 } // namespace extensions | 154 } // namespace extensions |
OLD | NEW |