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

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

Issue 23551005: Revert 219709 "Remove the Extensions URLRequestContext." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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"
12 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
14 13
15 namespace extensions { 14 namespace extensions {
16 15
17 namespace { 16 namespace {
18 17
19 class TestExtensionWarningService : public ExtensionWarningService { 18 class TestExtensionWarningService : public ExtensionWarningService {
20 public: 19 public:
21 explicit TestExtensionWarningService(Profile* profile) 20 explicit TestExtensionWarningService(Profile* profile)
(...skipping 19 matching lines...) Expand all
41 const ExtensionWarning::WarningType warning_1 = 40 const ExtensionWarning::WarningType warning_1 =
42 ExtensionWarning::kNetworkDelay; 41 ExtensionWarning::kNetworkDelay;
43 const ExtensionWarning::WarningType warning_2 = 42 const ExtensionWarning::WarningType warning_2 =
44 ExtensionWarning::kNetworkConflict; 43 ExtensionWarning::kNetworkConflict;
45 44
46 } // namespace 45 } // namespace
47 46
48 // Check that inserting a warning triggers notifications, whereas inserting 47 // Check that inserting a warning triggers notifications, whereas inserting
49 // the same warning again is silent. 48 // the same warning again is silent.
50 TEST(ExtensionWarningServiceTest, SetWarning) { 49 TEST(ExtensionWarningServiceTest, SetWarning) {
51 content::TestBrowserThreadBundle thread_bundle;
52 TestingProfile profile; 50 TestingProfile profile;
53 TestExtensionWarningService warning_service(&profile); 51 TestExtensionWarningService warning_service(&profile);
54 MockObserver observer; 52 MockObserver observer;
55 warning_service.AddObserver(&observer); 53 warning_service.AddObserver(&observer);
56 54
57 // Insert warning for the first time. 55 // Insert warning for the first time.
58 EXPECT_CALL(observer, ExtensionWarningsChanged()); 56 EXPECT_CALL(observer, ExtensionWarningsChanged());
59 warning_service.AddWarning( 57 warning_service.AddWarning(
60 ExtensionWarning::CreateNetworkDelayWarning(ext1_id)); 58 ExtensionWarning::CreateNetworkDelayWarning(ext1_id));
61 testing::Mock::VerifyAndClearExpectations(&warning_service); 59 testing::Mock::VerifyAndClearExpectations(&warning_service);
62 60
63 // Second insertion of same warning does not trigger anything. 61 // Second insertion of same warning does not trigger anything.
64 warning_service.AddWarning( 62 warning_service.AddWarning(
65 ExtensionWarning::CreateNetworkDelayWarning(ext1_id)); 63 ExtensionWarning::CreateNetworkDelayWarning(ext1_id));
66 testing::Mock::VerifyAndClearExpectations(&warning_service); 64 testing::Mock::VerifyAndClearExpectations(&warning_service);
67 65
68 warning_service.RemoveObserver(&observer); 66 warning_service.RemoveObserver(&observer);
69 } 67 }
70 68
71 // Check that ClearWarnings deletes exactly the specified warnings and 69 // Check that ClearWarnings deletes exactly the specified warnings and
72 // triggers notifications where appropriate. 70 // triggers notifications where appropriate.
73 TEST(ExtensionWarningServiceTest, ClearWarnings) { 71 TEST(ExtensionWarningServiceTest, ClearWarnings) {
74 content::TestBrowserThreadBundle thread_bundle;
75 TestingProfile profile; 72 TestingProfile profile;
76 TestExtensionWarningService warning_service(&profile); 73 TestExtensionWarningService warning_service(&profile);
77 MockObserver observer; 74 MockObserver observer;
78 warning_service.AddObserver(&observer); 75 warning_service.AddObserver(&observer);
79 76
80 // Insert two unique warnings in one batch. 77 // Insert two unique warnings in one batch.
81 EXPECT_CALL(observer, ExtensionWarningsChanged()); 78 EXPECT_CALL(observer, ExtensionWarningsChanged());
82 ExtensionWarningSet warning_set; 79 ExtensionWarningSet warning_set;
83 warning_set.insert(ExtensionWarning::CreateNetworkDelayWarning(ext1_id)); 80 warning_set.insert(ExtensionWarning::CreateNetworkDelayWarning(ext1_id));
84 warning_set.insert(ExtensionWarning::CreateNetworkConflictWarning(ext2_id)); 81 warning_set.insert(ExtensionWarning::CreateNetworkConflictWarning(ext2_id));
(...skipping 26 matching lines...) Expand all
111 warning_service.GetWarningTypesAffectingExtension(ext1_id); 108 warning_service.GetWarningTypesAffectingExtension(ext1_id);
112 EXPECT_EQ(0u, existing_warnings.size()); 109 EXPECT_EQ(0u, existing_warnings.size());
113 existing_warnings = 110 existing_warnings =
114 warning_service.GetWarningTypesAffectingExtension(ext2_id); 111 warning_service.GetWarningTypesAffectingExtension(ext2_id);
115 EXPECT_EQ(0u, existing_warnings.size()); 112 EXPECT_EQ(0u, existing_warnings.size());
116 113
117 warning_service.RemoveObserver(&observer); 114 warning_service.RemoveObserver(&observer);
118 } 115 }
119 116
120 } // namespace extensions 117 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698