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