| 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/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/global_error/global_error_service.h" | 9 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 10 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 10 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 11 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
| 12 #include "extensions/browser/warning_service.h" | 12 #include "extensions/browser/warning_service.h" |
| 13 #include "extensions/browser/warning_set.h" | 13 #include "extensions/browser/warning_set.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace extensions { | 16 namespace extensions { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 class TestExtensionWarningSet : public WarningService { | 20 class TestExtensionWarningSet : public WarningService { |
| 21 public: | 21 public: |
| 22 explicit TestExtensionWarningSet(Profile* profile) : WarningService(profile) { | 22 explicit TestExtensionWarningSet(Profile* profile) : WarningService(profile) { |
| 23 } | 23 } |
| 24 virtual ~TestExtensionWarningSet() {} | 24 ~TestExtensionWarningSet() override {} |
| 25 | 25 |
| 26 void AddWarning(const Warning& warning) { | 26 void AddWarning(const Warning& warning) { |
| 27 WarningSet warnings; | 27 WarningSet warnings; |
| 28 warnings.insert(warning); | 28 warnings.insert(warning); |
| 29 AddWarnings(warnings); | 29 AddWarnings(warnings); |
| 30 } | 30 } |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 class TestExtensionWarningBadgeService : public ExtensionWarningBadgeService { | 33 class TestExtensionWarningBadgeService : public ExtensionWarningBadgeService { |
| 34 public: | 34 public: |
| 35 TestExtensionWarningBadgeService(Profile* profile, | 35 TestExtensionWarningBadgeService(Profile* profile, |
| 36 WarningService* warning_service) | 36 WarningService* warning_service) |
| 37 : ExtensionWarningBadgeService(profile), | 37 : ExtensionWarningBadgeService(profile), |
| 38 warning_service_(warning_service) {} | 38 warning_service_(warning_service) {} |
| 39 virtual ~TestExtensionWarningBadgeService() {} | 39 ~TestExtensionWarningBadgeService() override {} |
| 40 | 40 |
| 41 virtual const std::set<Warning>& | 41 const std::set<Warning>& GetCurrentWarnings() const override { |
| 42 GetCurrentWarnings() const override { | |
| 43 return warning_service_->warnings(); | 42 return warning_service_->warnings(); |
| 44 } | 43 } |
| 45 | 44 |
| 46 private: | 45 private: |
| 47 WarningService* warning_service_; | 46 WarningService* warning_service_; |
| 48 }; | 47 }; |
| 49 | 48 |
| 50 bool HasBadge(Profile* profile) { | 49 bool HasBadge(Profile* profile) { |
| 51 GlobalErrorService* service = | 50 GlobalErrorService* service = |
| 52 GlobalErrorServiceFactory::GetForProfile(profile); | 51 GlobalErrorServiceFactory::GetForProfile(profile); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 EXPECT_FALSE(HasBadge(&profile)); | 85 EXPECT_FALSE(HasBadge(&profile)); |
| 87 | 86 |
| 88 // Set second warning and verify that it shows a badge. | 87 // Set second warning and verify that it shows a badge. |
| 89 warnings.AddWarning(Warning::CreateNetworkConflictWarning(ext2_id)); | 88 warnings.AddWarning(Warning::CreateNetworkConflictWarning(ext2_id)); |
| 90 EXPECT_TRUE(HasBadge(&profile)); | 89 EXPECT_TRUE(HasBadge(&profile)); |
| 91 | 90 |
| 92 warnings.RemoveObserver(&badge_service); | 91 warnings.RemoveObserver(&badge_service); |
| 93 } | 92 } |
| 94 | 93 |
| 95 } // namespace extensions | 94 } // namespace extensions |
| OLD | NEW |