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

Side by Side Diff: chrome/browser/policy/device_management_policy_provider_unittest.cc

Issue 5448001: Remove duplicate NotificationObserver mock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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
« no previous file with comments | « chrome/browser/password_manager/password_store_x_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/scoped_temp_dir.h" 7 #include "base/scoped_temp_dir.h"
8 #include "chrome/browser/browser_thread.h" 8 #include "chrome/browser/browser_thread.h"
9 #include "chrome/browser/net/gaia/token_service.h" 9 #include "chrome/browser/net/gaia/token_service.h"
10 #include "chrome/browser/policy/configuration_policy_pref_store.h" 10 #include "chrome/browser/policy/configuration_policy_pref_store.h"
11 #include "chrome/browser/policy/device_management_policy_cache.h" 11 #include "chrome/browser/policy/device_management_policy_cache.h"
12 #include "chrome/browser/policy/device_management_policy_provider.h" 12 #include "chrome/browser/policy/device_management_policy_provider.h"
13 #include "chrome/browser/policy/mock_configuration_policy_store.h" 13 #include "chrome/browser/policy/mock_configuration_policy_store.h"
14 #include "chrome/browser/policy/mock_device_management_backend.h" 14 #include "chrome/browser/policy/mock_device_management_backend.h"
15 #include "chrome/common/net/gaia/gaia_constants.h" 15 #include "chrome/common/net/gaia/gaia_constants.h"
16 #include "chrome/common/notification_observer_mock.h"
16 #include "chrome/common/notification_service.h" 17 #include "chrome/common/notification_service.h"
17 #include "chrome/common/policy_constants.h" 18 #include "chrome/common/policy_constants.h"
18 #include "chrome/test/mock_notification_observer.h"
19 #include "chrome/test/testing_device_token_fetcher.h" 19 #include "chrome/test/testing_device_token_fetcher.h"
20 #include "chrome/test/testing_profile.h" 20 #include "chrome/test/testing_profile.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 const char kTestToken[] = "device_policy_provider_test_auth_token"; 23 const char kTestToken[] = "device_policy_provider_test_auth_token";
24 24
25 namespace policy { 25 namespace policy {
26 26
27 using ::testing::_; 27 using ::testing::_;
28 using ::testing::InSequence; 28 using ::testing::InSequence;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 loop_.RunAllPending(); 186 loop_.RunAllPending();
187 SimulateSuccessfulLoginAndRunPending(); 187 SimulateSuccessfulLoginAndRunPending();
188 EXPECT_CALL(store, Apply(kPolicyDisableSpdy, _)).Times(1); 188 EXPECT_CALL(store, Apply(kPolicyDisableSpdy, _)).Times(1);
189 provider_->Provide(&store); 189 provider_->Provide(&store);
190 ASSERT_EQ(1U, store.policy_map().size()); 190 ASSERT_EQ(1U, store.policy_map().size());
191 } 191 }
192 192
193 // When policy is successfully fetched from the device management server, it 193 // When policy is successfully fetched from the device management server, it
194 // should force a policy refresh. 194 // should force a policy refresh.
195 TEST_F(DeviceManagementPolicyProviderTest, FetchTriggersRefresh) { 195 TEST_F(DeviceManagementPolicyProviderTest, FetchTriggersRefresh) {
196 MockNotificationObserver observer; 196 NotificationObserverMock observer;
197 NotificationRegistrar registrar; 197 NotificationRegistrar registrar;
198 registrar.Add(&observer, 198 registrar.Add(&observer,
199 NotificationType::POLICY_CHANGED, 199 NotificationType::POLICY_CHANGED,
200 NotificationService::AllSources()); 200 NotificationService::AllSources());
201 EXPECT_CALL(observer, Observe(_, _, _)).Times(1); 201 EXPECT_CALL(observer, Observe(_, _, _)).Times(1);
202 SimulateSuccessfulInitialPolicyFetch(); 202 SimulateSuccessfulInitialPolicyFetch();
203 } 203 }
204 204
205 TEST_F(DeviceManagementPolicyProviderTest, ErrorCausesNewRequest) { 205 TEST_F(DeviceManagementPolicyProviderTest, ErrorCausesNewRequest) {
206 InSequence s; 206 InSequence s;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 MockDeviceManagementBackendSucceedRegister()); 310 MockDeviceManagementBackendSucceedRegister());
311 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 311 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
312 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true)); 312 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true));
313 SimulateSuccessfulLoginAndRunPending(); 313 SimulateSuccessfulLoginAndRunPending();
314 // (3) Since the backend call this time returned a device id, the "unmanaged" 314 // (3) Since the backend call this time returned a device id, the "unmanaged"
315 // marker should have been deleted. 315 // marker should have been deleted.
316 EXPECT_FALSE(cache(provider_.get())->is_device_unmanaged()); 316 EXPECT_FALSE(cache(provider_.get())->is_device_unmanaged());
317 } 317 }
318 318
319 } // namespace policy 319 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_x_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698