| 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/warning_badge_service.h" | 5 #include "chrome/browser/extensions/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 "content/public/test/test_browser_thread_bundle.h" |
| 12 #include "extensions/browser/warning_service.h" | 13 #include "extensions/browser/warning_service.h" |
| 13 #include "extensions/browser/warning_set.h" | 14 #include "extensions/browser/warning_set.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 namespace extensions { | 17 namespace extensions { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 class TestExtensionWarningSet : public WarningService { | 21 class TestExtensionWarningSet : public WarningService { |
| 21 public: | 22 public: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 52 } | 53 } |
| 53 | 54 |
| 54 const char ext1_id[] = "extension1"; | 55 const char ext1_id[] = "extension1"; |
| 55 const char ext2_id[] = "extension2"; | 56 const char ext2_id[] = "extension2"; |
| 56 | 57 |
| 57 } // namespace | 58 } // namespace |
| 58 | 59 |
| 59 // Check that no badge appears if it has been suppressed for a specific | 60 // Check that no badge appears if it has been suppressed for a specific |
| 60 // warning. | 61 // warning. |
| 61 TEST(WarningBadgeServiceTest, SuppressBadgeForCurrentWarnings) { | 62 TEST(WarningBadgeServiceTest, SuppressBadgeForCurrentWarnings) { |
| 63 content::TestBrowserThreadBundle thread_bundle; |
| 62 TestingProfile profile; | 64 TestingProfile profile; |
| 63 TestExtensionWarningSet warnings(&profile); | 65 TestExtensionWarningSet warnings(&profile); |
| 64 TestWarningBadgeService badge_service(&profile, &warnings); | 66 TestWarningBadgeService badge_service(&profile, &warnings); |
| 65 warnings.AddObserver(&badge_service); | 67 warnings.AddObserver(&badge_service); |
| 66 | 68 |
| 67 // Insert first warning. | 69 // Insert first warning. |
| 68 warnings.AddWarning(Warning::CreateNetworkDelayWarning(ext1_id)); | 70 warnings.AddWarning(Warning::CreateNetworkDelayWarning(ext1_id)); |
| 69 EXPECT_TRUE(HasBadge(&profile)); | 71 EXPECT_TRUE(HasBadge(&profile)); |
| 70 | 72 |
| 71 // Suppress first warning. | 73 // Suppress first warning. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 83 EXPECT_FALSE(HasBadge(&profile)); | 85 EXPECT_FALSE(HasBadge(&profile)); |
| 84 | 86 |
| 85 // Set second warning and verify that it shows a badge. | 87 // Set second warning and verify that it shows a badge. |
| 86 warnings.AddWarning(Warning::CreateNetworkConflictWarning(ext2_id)); | 88 warnings.AddWarning(Warning::CreateNetworkConflictWarning(ext2_id)); |
| 87 EXPECT_TRUE(HasBadge(&profile)); | 89 EXPECT_TRUE(HasBadge(&profile)); |
| 88 | 90 |
| 89 warnings.RemoveObserver(&badge_service); | 91 warnings.RemoveObserver(&badge_service); |
| 90 } | 92 } |
| 91 | 93 |
| 92 } // namespace extensions | 94 } // namespace extensions |
| OLD | NEW |