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

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

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix InstantNTP test. Created 7 years, 5 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/policy/policy_service_impl.h" 5 #include "chrome/browser/policy/policy_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 12 #include "base/run_loop.h"
14 #include "base/values.h" 13 #include "base/values.h"
15 #include "chrome/browser/policy/external_data_fetcher.h" 14 #include "chrome/browser/policy/external_data_fetcher.h"
16 #include "chrome/browser/policy/mock_configuration_policy_provider.h" 15 #include "chrome/browser/policy/mock_configuration_policy_provider.h"
17 #include "chrome/browser/policy/mock_policy_service.h" 16 #include "chrome/browser/policy/mock_policy_service.h"
18 #include "chrome/browser/policy/policy_domain_descriptor.h" 17 #include "chrome/browser/policy/policy_domain_descriptor.h"
19 #include "chrome/common/policy/policy_schema.h" 18 #include "chrome/common/policy/policy_schema.h"
20 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
21 #include "content/public/test/test_browser_thread.h" 20 #include "content/public/test/test_browser_thread_bundle.h"
22 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
24 23
25 using ::testing::AnyNumber; 24 using ::testing::AnyNumber;
26 using ::testing::Mock; 25 using ::testing::Mock;
27 using ::testing::Return; 26 using ::testing::Return;
28 using ::testing::_; 27 using ::testing::_;
29 28
30 namespace policy { 29 namespace policy {
31 30
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 147 }
149 148
150 protected: 149 protected:
151 MockConfigurationPolicyProvider provider0_; 150 MockConfigurationPolicyProvider provider0_;
152 MockConfigurationPolicyProvider provider1_; 151 MockConfigurationPolicyProvider provider1_;
153 MockConfigurationPolicyProvider provider2_; 152 MockConfigurationPolicyProvider provider2_;
154 PolicyMap policy0_; 153 PolicyMap policy0_;
155 PolicyMap policy1_; 154 PolicyMap policy1_;
156 PolicyMap policy2_; 155 PolicyMap policy2_;
157 scoped_ptr<PolicyServiceImpl> policy_service_; 156 scoped_ptr<PolicyServiceImpl> policy_service_;
158 base::MessageLoop loop_; 157 content::TestBrowserThreadBundle thread_bundle_;
159 158
160 private: 159 private:
161 DISALLOW_COPY_AND_ASSIGN(PolicyServiceTest); 160 DISALLOW_COPY_AND_ASSIGN(PolicyServiceTest);
162 }; 161 };
163 162
164 TEST_F(PolicyServiceTest, LoadsPoliciesBeforeProvidersRefresh) { 163 TEST_F(PolicyServiceTest, LoadsPoliciesBeforeProvidersRefresh) {
165 PolicyMap expected; 164 PolicyMap expected;
166 expected.Set("pre", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 165 expected.Set("pre", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
167 base::Value::CreateIntegerValue(13), NULL); 166 base::Value::CreateIntegerValue(13), NULL);
168 EXPECT_TRUE(VerifyPolicies( 167 EXPECT_TRUE(VerifyPolicies(
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 registrar.reset(); 428 registrar.reset();
430 policy0_.Set("aaa", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 429 policy0_.Set("aaa", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
431 kValue1.DeepCopy(), NULL); 430 kValue1.DeepCopy(), NULL);
432 policy0_.Set("pre", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 431 policy0_.Set("pre", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
433 kValue1.DeepCopy(), NULL); 432 kValue1.DeepCopy(), NULL);
434 UpdateProviderPolicy(policy0_); 433 UpdateProviderPolicy(policy0_);
435 Mock::VerifyAndClearExpectations(this); 434 Mock::VerifyAndClearExpectations(this);
436 } 435 }
437 436
438 TEST_F(PolicyServiceTest, RefreshPolicies) { 437 TEST_F(PolicyServiceTest, RefreshPolicies) {
439 content::TestBrowserThread ui_thread(content::BrowserThread::UI, &loop_);
440 content::TestBrowserThread file_thread(content::BrowserThread::FILE, &loop_);
441 content::TestBrowserThread io_thread(content::BrowserThread::IO, &loop_);
442
443 EXPECT_CALL(provider0_, RefreshPolicies()).Times(AnyNumber()); 438 EXPECT_CALL(provider0_, RefreshPolicies()).Times(AnyNumber());
444 EXPECT_CALL(provider1_, RefreshPolicies()).Times(AnyNumber()); 439 EXPECT_CALL(provider1_, RefreshPolicies()).Times(AnyNumber());
445 EXPECT_CALL(provider2_, RefreshPolicies()).Times(AnyNumber()); 440 EXPECT_CALL(provider2_, RefreshPolicies()).Times(AnyNumber());
446 441
447 EXPECT_CALL(*this, OnPolicyRefresh()).Times(0); 442 EXPECT_CALL(*this, OnPolicyRefresh()).Times(0);
448 policy_service_->RefreshPolicies(base::Bind( 443 policy_service_->RefreshPolicies(base::Bind(
449 &PolicyServiceTest::OnPolicyRefresh, 444 &PolicyServiceTest::OnPolicyRefresh,
450 base::Unretained(this))); 445 base::Unretained(this)));
451 // Let any queued observer tasks run. 446 // Let any queued observer tasks run.
452 RunUntilIdle(); 447 RunUntilIdle();
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 scoped_refptr<PolicyDomainDescriptor> empty_extensions_descriptor = 672 scoped_refptr<PolicyDomainDescriptor> empty_extensions_descriptor =
678 new PolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS); 673 new PolicyDomainDescriptor(POLICY_DOMAIN_EXTENSIONS);
679 EXPECT_CALL(provider0_, RegisterPolicyDomain( 674 EXPECT_CALL(provider0_, RegisterPolicyDomain(
680 scoped_refptr<const PolicyDomainDescriptor>( 675 scoped_refptr<const PolicyDomainDescriptor>(
681 empty_extensions_descriptor))); 676 empty_extensions_descriptor)));
682 policy_service_->RegisterPolicyDomain(empty_extensions_descriptor); 677 policy_service_->RegisterPolicyDomain(empty_extensions_descriptor);
683 Mock::VerifyAndClearExpectations(&provider0_); 678 Mock::VerifyAndClearExpectations(&provider0_);
684 } 679 }
685 680
686 } // namespace policy 681 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698