Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: chrome/browser/extensions/extension_warning_service_unittest.cc

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android webview init fix merged in. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_service.h" 5 #include "chrome/browser/extensions/extension_warning_service.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/global_error/global_error_service.h" 8 #include "chrome/browser/ui/global_error/global_error_service.h"
9 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 9 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
11 #include "content/public/test/test_browser_thread_bundle.h"
11 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace extensions { 15 namespace extensions {
15 16
16 namespace { 17 namespace {
17 18
18 class TestExtensionWarningService : public ExtensionWarningService { 19 class TestExtensionWarningService : public ExtensionWarningService {
19 public: 20 public:
20 explicit TestExtensionWarningService(Profile* profile) 21 explicit TestExtensionWarningService(Profile* profile)
(...skipping 19 matching lines...) Expand all
40 const ExtensionWarning::WarningType warning_1 = 41 const ExtensionWarning::WarningType warning_1 =
41 ExtensionWarning::kNetworkDelay; 42 ExtensionWarning::kNetworkDelay;
42 const ExtensionWarning::WarningType warning_2 = 43 const ExtensionWarning::WarningType warning_2 =
43 ExtensionWarning::kNetworkConflict; 44 ExtensionWarning::kNetworkConflict;
44 45
45 } // namespace 46 } // namespace
46 47
47 // Check that inserting a warning triggers notifications, whereas inserting 48 // Check that inserting a warning triggers notifications, whereas inserting
48 // the same warning again is silent. 49 // the same warning again is silent.
49 TEST(ExtensionWarningServiceTest, SetWarning) { 50 TEST(ExtensionWarningServiceTest, SetWarning) {
51 content::TestBrowserThreadBundle thread_bundle;
50 TestingProfile profile; 52 TestingProfile profile;
51 TestExtensionWarningService warning_service(&profile); 53 TestExtensionWarningService warning_service(&profile);
52 MockObserver observer; 54 MockObserver observer;
53 warning_service.AddObserver(&observer); 55 warning_service.AddObserver(&observer);
54 56
55 // Insert warning for the first time. 57 // Insert warning for the first time.
56 EXPECT_CALL(observer, ExtensionWarningsChanged()); 58 EXPECT_CALL(observer, ExtensionWarningsChanged());
57 warning_service.AddWarning( 59 warning_service.AddWarning(
58 ExtensionWarning::CreateNetworkDelayWarning(ext1_id)); 60 ExtensionWarning::CreateNetworkDelayWarning(ext1_id));
59 testing::Mock::VerifyAndClearExpectations(&warning_service); 61 testing::Mock::VerifyAndClearExpectations(&warning_service);
60 62
61 // Second insertion of same warning does not trigger anything. 63 // Second insertion of same warning does not trigger anything.
62 warning_service.AddWarning( 64 warning_service.AddWarning(
63 ExtensionWarning::CreateNetworkDelayWarning(ext1_id)); 65 ExtensionWarning::CreateNetworkDelayWarning(ext1_id));
64 testing::Mock::VerifyAndClearExpectations(&warning_service); 66 testing::Mock::VerifyAndClearExpectations(&warning_service);
65 67
66 warning_service.RemoveObserver(&observer); 68 warning_service.RemoveObserver(&observer);
67 } 69 }
68 70
69 // Check that ClearWarnings deletes exactly the specified warnings and 71 // Check that ClearWarnings deletes exactly the specified warnings and
70 // triggers notifications where appropriate. 72 // triggers notifications where appropriate.
71 TEST(ExtensionWarningServiceTest, ClearWarnings) { 73 TEST(ExtensionWarningServiceTest, ClearWarnings) {
74 content::TestBrowserThreadBundle thread_bundle;
72 TestingProfile profile; 75 TestingProfile profile;
73 TestExtensionWarningService warning_service(&profile); 76 TestExtensionWarningService warning_service(&profile);
74 MockObserver observer; 77 MockObserver observer;
75 warning_service.AddObserver(&observer); 78 warning_service.AddObserver(&observer);
76 79
77 // Insert two unique warnings in one batch. 80 // Insert two unique warnings in one batch.
78 EXPECT_CALL(observer, ExtensionWarningsChanged()); 81 EXPECT_CALL(observer, ExtensionWarningsChanged());
79 ExtensionWarningSet warning_set; 82 ExtensionWarningSet warning_set;
80 warning_set.insert(ExtensionWarning::CreateNetworkDelayWarning(ext1_id)); 83 warning_set.insert(ExtensionWarning::CreateNetworkDelayWarning(ext1_id));
81 warning_set.insert(ExtensionWarning::CreateNetworkConflictWarning(ext2_id)); 84 warning_set.insert(ExtensionWarning::CreateNetworkConflictWarning(ext2_id));
(...skipping 26 matching lines...) Expand all
108 warning_service.GetWarningTypesAffectingExtension(ext1_id); 111 warning_service.GetWarningTypesAffectingExtension(ext1_id);
109 EXPECT_EQ(0u, existing_warnings.size()); 112 EXPECT_EQ(0u, existing_warnings.size());
110 existing_warnings = 113 existing_warnings =
111 warning_service.GetWarningTypesAffectingExtension(ext2_id); 114 warning_service.GetWarningTypesAffectingExtension(ext2_id);
112 EXPECT_EQ(0u, existing_warnings.size()); 115 EXPECT_EQ(0u, existing_warnings.size());
113 116
114 warning_service.RemoveObserver(&observer); 117 warning_service.RemoveObserver(&observer);
115 } 118 }
116 119
117 } // namespace extensions 120 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698