| OLD | NEW |
| 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/browser/extensions/extension_warning_badge_service.h" | 5 #include "chrome/browser/extensions/extension_warning_badge_service.h" |
| 6 | 6 |
| 7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/extensions/extension_warning_set.h" | 8 #include "chrome/browser/extensions/extension_warning_set.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/global_error/global_error_service.h" | 10 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 11 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 11 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 14 |
| 16 namespace extensions { | 15 namespace extensions { |
| 17 | 16 |
| 18 namespace { | 17 namespace { |
| 19 | 18 |
| 20 class TestExtensionWarningSet : public ExtensionWarningService { | 19 class TestExtensionWarningSet : public ExtensionWarningService { |
| 21 public: | 20 public: |
| 22 explicit TestExtensionWarningSet(Profile* profile) | 21 explicit TestExtensionWarningSet(Profile* profile) |
| 23 : ExtensionWarningService(profile) { | 22 : ExtensionWarningService(profile) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 const ExtensionWarning::WarningType warning_1 = | 59 const ExtensionWarning::WarningType warning_1 = |
| 61 ExtensionWarning::kNetworkDelay; | 60 ExtensionWarning::kNetworkDelay; |
| 62 const ExtensionWarning::WarningType warning_2 = | 61 const ExtensionWarning::WarningType warning_2 = |
| 63 ExtensionWarning::kNetworkConflict; | 62 ExtensionWarning::kNetworkConflict; |
| 64 | 63 |
| 65 } // namespace | 64 } // namespace |
| 66 | 65 |
| 67 // Check that no badge appears if it has been suppressed for a specific | 66 // Check that no badge appears if it has been suppressed for a specific |
| 68 // warning. | 67 // warning. |
| 69 TEST(ExtensionWarningBadgeServiceTest, SuppressBadgeForCurrentWarnings) { | 68 TEST(ExtensionWarningBadgeServiceTest, SuppressBadgeForCurrentWarnings) { |
| 70 content::TestBrowserThreadBundle thread_bundle; | |
| 71 TestingProfile profile; | 69 TestingProfile profile; |
| 72 TestExtensionWarningSet warnings(&profile); | 70 TestExtensionWarningSet warnings(&profile); |
| 73 TestExtensionWarningBadgeService badge_service(&profile, &warnings); | 71 TestExtensionWarningBadgeService badge_service(&profile, &warnings); |
| 74 warnings.AddObserver(&badge_service); | 72 warnings.AddObserver(&badge_service); |
| 75 | 73 |
| 76 // Insert first warning. | 74 // Insert first warning. |
| 77 warnings.AddWarning(ExtensionWarning::CreateNetworkDelayWarning(ext1_id)); | 75 warnings.AddWarning(ExtensionWarning::CreateNetworkDelayWarning(ext1_id)); |
| 78 EXPECT_TRUE(HasBadge(&profile)); | 76 EXPECT_TRUE(HasBadge(&profile)); |
| 79 | 77 |
| 80 // Suppress first warning. | 78 // Suppress first warning. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 92 EXPECT_FALSE(HasBadge(&profile)); | 90 EXPECT_FALSE(HasBadge(&profile)); |
| 93 | 91 |
| 94 // Set second warning and verify that it shows a badge. | 92 // Set second warning and verify that it shows a badge. |
| 95 warnings.AddWarning(ExtensionWarning::CreateNetworkConflictWarning(ext2_id)); | 93 warnings.AddWarning(ExtensionWarning::CreateNetworkConflictWarning(ext2_id)); |
| 96 EXPECT_TRUE(HasBadge(&profile)); | 94 EXPECT_TRUE(HasBadge(&profile)); |
| 97 | 95 |
| 98 warnings.RemoveObserver(&badge_service); | 96 warnings.RemoveObserver(&badge_service); |
| 99 } | 97 } |
| 100 | 98 |
| 101 } // namespace extensions | 99 } // namespace extensions |
| OLD | NEW |