| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 protected: | 48 protected: |
| 49 content::TestBrowserThreadBundle thread_bundle_; | 49 content::TestBrowserThreadBundle thread_bundle_; |
| 50 scoped_ptr<TestingProfile> profile_; | 50 scoped_ptr<TestingProfile> profile_; |
| 51 ErrorConsole* error_console_; | 51 ErrorConsole* error_console_; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 // Test that the error console is enabled/disabled appropriately. | 54 // Test that the error console is enabled/disabled appropriately. |
| 55 TEST_F(ErrorConsoleUnitTest, EnableAndDisableErrorConsole) { | 55 TEST_F(ErrorConsoleUnitTest, EnableAndDisableErrorConsole) { |
| 56 // Start in Dev Channel, without the feature switch. | 56 // Start in Dev Channel, without the feature switch. |
| 57 scoped_ptr<ScopedCurrentChannel> channel_override( | 57 scoped_ptr<ScopedCurrentChannel> channel_override( |
| 58 new ScopedCurrentChannel(chrome::VersionInfo::CHANNEL_DEV)); | 58 new ScopedCurrentChannel(version_info::Channel::DEV)); |
| 59 ASSERT_EQ(chrome::VersionInfo::CHANNEL_DEV, GetCurrentChannel()); | 59 ASSERT_EQ(version_info::Channel::DEV, GetCurrentChannel()); |
| 60 FeatureSwitch::error_console()->SetOverrideValue( | 60 FeatureSwitch::error_console()->SetOverrideValue( |
| 61 FeatureSwitch::OVERRIDE_DISABLED); | 61 FeatureSwitch::OVERRIDE_DISABLED); |
| 62 | 62 |
| 63 // At the start, the error console should be enabled, and specifically | 63 // At the start, the error console should be enabled, and specifically |
| 64 // enabled for the chrome:extensions page. | 64 // enabled for the chrome:extensions page. |
| 65 EXPECT_TRUE(error_console_->enabled()); | 65 EXPECT_TRUE(error_console_->enabled()); |
| 66 EXPECT_TRUE(error_console_->IsEnabledForChromeExtensionsPage()); | 66 EXPECT_TRUE(error_console_->IsEnabledForChromeExtensionsPage()); |
| 67 EXPECT_FALSE(error_console_->IsEnabledForAppsDeveloperTools()); | 67 EXPECT_FALSE(error_console_->IsEnabledForAppsDeveloperTools()); |
| 68 | 68 |
| 69 // If we disable developer mode, we should disable error console. | 69 // If we disable developer mode, we should disable error console. |
| 70 profile_->GetPrefs()->SetBoolean(prefs::kExtensionsUIDeveloperMode, false); | 70 profile_->GetPrefs()->SetBoolean(prefs::kExtensionsUIDeveloperMode, false); |
| 71 EXPECT_FALSE(error_console_->enabled()); | 71 EXPECT_FALSE(error_console_->enabled()); |
| 72 EXPECT_FALSE(error_console_->IsEnabledForChromeExtensionsPage()); | 72 EXPECT_FALSE(error_console_->IsEnabledForChromeExtensionsPage()); |
| 73 EXPECT_FALSE(error_console_->IsEnabledForAppsDeveloperTools()); | 73 EXPECT_FALSE(error_console_->IsEnabledForAppsDeveloperTools()); |
| 74 | 74 |
| 75 // Similarly, if we change the current to less fun than Dev, ErrorConsole | 75 // Similarly, if we change the current to less fun than Dev, ErrorConsole |
| 76 // should be disabled. | 76 // should be disabled. |
| 77 channel_override.reset(); | 77 channel_override.reset(); |
| 78 channel_override.reset( | 78 channel_override.reset( |
| 79 new ScopedCurrentChannel(chrome::VersionInfo::CHANNEL_BETA)); | 79 new ScopedCurrentChannel(version_info::Channel::BETA)); |
| 80 profile_->GetPrefs()->SetBoolean(prefs::kExtensionsUIDeveloperMode, true); | 80 profile_->GetPrefs()->SetBoolean(prefs::kExtensionsUIDeveloperMode, true); |
| 81 EXPECT_FALSE(error_console_->enabled()); | 81 EXPECT_FALSE(error_console_->enabled()); |
| 82 EXPECT_FALSE(error_console_->IsEnabledForChromeExtensionsPage()); | 82 EXPECT_FALSE(error_console_->IsEnabledForChromeExtensionsPage()); |
| 83 EXPECT_FALSE(error_console_->IsEnabledForAppsDeveloperTools()); | 83 EXPECT_FALSE(error_console_->IsEnabledForAppsDeveloperTools()); |
| 84 | 84 |
| 85 // But if we add the feature switch, that should override the channel. | 85 // But if we add the feature switch, that should override the channel. |
| 86 FeatureSwitch::error_console()->SetOverrideValue( | 86 FeatureSwitch::error_console()->SetOverrideValue( |
| 87 FeatureSwitch::OVERRIDE_ENABLED); | 87 FeatureSwitch::OVERRIDE_ENABLED); |
| 88 ASSERT_TRUE(FeatureSwitch::error_console()->IsEnabled()); | 88 ASSERT_TRUE(FeatureSwitch::error_console()->IsEnabled()); |
| 89 // We use a pref mod to "poke" the ErrorConsole, because it needs an | 89 // We use a pref mod to "poke" the ErrorConsole, because it needs an |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 error_console_->ReportError( | 269 error_console_->ReportError( |
| 270 CreateNewRuntimeError(packed_extension->id(), "runtime error 4")); | 270 CreateNewRuntimeError(packed_extension->id(), "runtime error 4")); |
| 271 EXPECT_EQ(2u, // We should still have the first two errors. | 271 EXPECT_EQ(2u, // We should still have the first two errors. |
| 272 error_console_->GetErrorsForExtension( | 272 error_console_->GetErrorsForExtension( |
| 273 unpacked_extension->id()).size()); | 273 unpacked_extension->id()).size()); |
| 274 EXPECT_FALSE(error_console_->IsReportingEnabledForExtension( | 274 EXPECT_FALSE(error_console_->IsReportingEnabledForExtension( |
| 275 unpacked_extension->id())); | 275 unpacked_extension->id())); |
| 276 } | 276 } |
| 277 | 277 |
| 278 } // namespace extensions | 278 } // namespace extensions |
| OLD | NEW |