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

Side by Side Diff: extensions/browser/warning_service_unittest.cc

Issue 2915523002: Replace deprecated base::NonThreadSafe in extensions in favor of SequenceChecker. (Closed)
Patch Set: Add TestBrowserThreadBundle Created 3 years, 6 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
« no previous file with comments | « extensions/browser/warning_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "extensions/browser/warning_service.h" 5 #include "extensions/browser/warning_service.h"
6 6
7 #include "content/public/test/test_browser_context.h" 7 #include "content/public/test/test_browser_context.h"
8 #include "content/public/test/test_browser_thread_bundle.h"
8 #include "extensions/browser/extensions_test.h" 9 #include "extensions/browser/extensions_test.h"
9 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace extensions { 13 namespace extensions {
13 14
14 namespace { 15 namespace {
15 16
16 class TestWarningService : public WarningService { 17 class TestWarningService : public WarningService {
17 public: 18 public:
(...skipping 20 matching lines...) Expand all
38 const char ext1_id[] = "extension1"; 39 const char ext1_id[] = "extension1";
39 const char ext2_id[] = "extension2"; 40 const char ext2_id[] = "extension2";
40 const Warning::WarningType warning_1 = Warning::kNetworkDelay; 41 const Warning::WarningType warning_1 = Warning::kNetworkDelay;
41 const Warning::WarningType warning_2 = Warning::kNetworkConflict; 42 const Warning::WarningType warning_2 = Warning::kNetworkConflict;
42 43
43 } // namespace 44 } // namespace
44 45
45 // Check that inserting a warning triggers notifications, whereas inserting 46 // Check that inserting a warning triggers notifications, whereas inserting
46 // the same warning again is silent. 47 // the same warning again is silent.
47 TEST_F(WarningServiceTest, SetWarning) { 48 TEST_F(WarningServiceTest, SetWarning) {
49 content::TestBrowserThreadBundle thread_bundle_;
48 content::TestBrowserContext browser_context; 50 content::TestBrowserContext browser_context;
49 TestWarningService warning_service(&browser_context); 51 TestWarningService warning_service(&browser_context);
50 MockObserver observer; 52 MockObserver observer;
51 warning_service.AddObserver(&observer); 53 warning_service.AddObserver(&observer);
52 54
53 ExtensionIdSet affected_extensions; 55 ExtensionIdSet affected_extensions;
54 affected_extensions.insert(ext1_id); 56 affected_extensions.insert(ext1_id);
55 // Insert warning for the first time. 57 // Insert warning for the first time.
56 EXPECT_CALL(observer, ExtensionWarningsChanged(affected_extensions)); 58 EXPECT_CALL(observer, ExtensionWarningsChanged(affected_extensions));
57 warning_service.AddWarning( 59 warning_service.AddWarning(
58 Warning::CreateNetworkDelayWarning(ext1_id)); 60 Warning::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(Warning::CreateNetworkDelayWarning(ext1_id)); 64 warning_service.AddWarning(Warning::CreateNetworkDelayWarning(ext1_id));
63 testing::Mock::VerifyAndClearExpectations(&warning_service); 65 testing::Mock::VerifyAndClearExpectations(&warning_service);
64 66
65 warning_service.RemoveObserver(&observer); 67 warning_service.RemoveObserver(&observer);
66 } 68 }
67 69
68 // Check that ClearWarnings deletes exactly the specified warnings and 70 // Check that ClearWarnings deletes exactly the specified warnings and
69 // triggers notifications where appropriate. 71 // triggers notifications where appropriate.
70 TEST_F(WarningServiceTest, ClearWarnings) { 72 TEST_F(WarningServiceTest, ClearWarnings) {
73 content::TestBrowserThreadBundle thread_bundle_;
71 content::TestBrowserContext browser_context; 74 content::TestBrowserContext browser_context;
72 TestWarningService warning_service(&browser_context); 75 TestWarningService warning_service(&browser_context);
73 MockObserver observer; 76 MockObserver observer;
74 warning_service.AddObserver(&observer); 77 warning_service.AddObserver(&observer);
75 78
76 // Insert two unique warnings in one batch. 79 // Insert two unique warnings in one batch.
77 std::set<std::string> affected_extensions; 80 std::set<std::string> affected_extensions;
78 affected_extensions.insert(ext1_id); 81 affected_extensions.insert(ext1_id);
79 affected_extensions.insert(ext2_id); 82 affected_extensions.insert(ext2_id);
80 EXPECT_CALL(observer, ExtensionWarningsChanged(affected_extensions)); 83 EXPECT_CALL(observer, ExtensionWarningsChanged(affected_extensions));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 warning_service.GetWarningTypesAffectingExtension(ext1_id); 117 warning_service.GetWarningTypesAffectingExtension(ext1_id);
115 EXPECT_EQ(0u, existing_warnings.size()); 118 EXPECT_EQ(0u, existing_warnings.size());
116 existing_warnings = 119 existing_warnings =
117 warning_service.GetWarningTypesAffectingExtension(ext2_id); 120 warning_service.GetWarningTypesAffectingExtension(ext2_id);
118 EXPECT_EQ(0u, existing_warnings.size()); 121 EXPECT_EQ(0u, existing_warnings.size());
119 122
120 warning_service.RemoveObserver(&observer); 123 warning_service.RemoveObserver(&observer);
121 } 124 }
122 125
123 } // namespace extensions 126 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/warning_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698