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

Side by Side Diff: components/policy/core/common/async_policy_provider_unittest.cc

Issue 1304843004: Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed browsertest and removed unnecessary string for default values. Created 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/policy/core/common/async_policy_provider.h" 5 #include "components/policy/core/common/async_policy_provider.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 29 matching lines...) Expand all
40 public: 40 public:
41 explicit MockPolicyLoader( 41 explicit MockPolicyLoader(
42 scoped_refptr<base::SequencedTaskRunner> task_runner); 42 scoped_refptr<base::SequencedTaskRunner> task_runner);
43 ~MockPolicyLoader() override; 43 ~MockPolicyLoader() override;
44 44
45 // Load() returns a scoped_ptr<PolicyBundle> but it can't be mocked because 45 // Load() returns a scoped_ptr<PolicyBundle> but it can't be mocked because
46 // scoped_ptr is moveable but not copyable. This override forwards the 46 // scoped_ptr is moveable but not copyable. This override forwards the
47 // call to MockLoad() which returns a PolicyBundle*, and returns a copy 47 // call to MockLoad() which returns a PolicyBundle*, and returns a copy
48 // wrapped in a passed scoped_ptr. 48 // wrapped in a passed scoped_ptr.
49 scoped_ptr<PolicyBundle> Load() override; 49 scoped_ptr<PolicyBundle> Load() override;
50 PolicySource source() const override;
Thiemo Nagel 2015/09/01 17:40:36 Remove.
fhorschig 2015/09/04 06:53:54 Done.
50 51
51 MOCK_METHOD0(MockLoad, const PolicyBundle*()); 52 MOCK_METHOD0(MockLoad, const PolicyBundle*());
52 MOCK_METHOD0(InitOnBackgroundThread, void()); 53 MOCK_METHOD0(InitOnBackgroundThread, void());
53 MOCK_METHOD0(LastModificationTime, base::Time()); 54 MOCK_METHOD0(LastModificationTime, base::Time());
54 55
55 private: 56 private:
56 DISALLOW_COPY_AND_ASSIGN(MockPolicyLoader); 57 DISALLOW_COPY_AND_ASSIGN(MockPolicyLoader);
57 }; 58 };
58 59
59 MockPolicyLoader::MockPolicyLoader( 60 MockPolicyLoader::MockPolicyLoader(
60 scoped_refptr<base::SequencedTaskRunner> task_runner) 61 scoped_refptr<base::SequencedTaskRunner> task_runner)
61 : AsyncPolicyLoader(task_runner) {} 62 : AsyncPolicyLoader(task_runner) {}
62 63
63 MockPolicyLoader::~MockPolicyLoader() {} 64 MockPolicyLoader::~MockPolicyLoader() {}
64 65
65 scoped_ptr<PolicyBundle> MockPolicyLoader::Load() { 66 scoped_ptr<PolicyBundle> MockPolicyLoader::Load() {
66 scoped_ptr<PolicyBundle> bundle; 67 scoped_ptr<PolicyBundle> bundle;
67 const PolicyBundle* loaded = MockLoad(); 68 const PolicyBundle* loaded = MockLoad();
68 if (loaded) { 69 if (loaded) {
69 bundle.reset(new PolicyBundle()); 70 bundle.reset(new PolicyBundle());
70 bundle->CopyFrom(*loaded); 71 bundle->CopyFrom(*loaded);
71 } 72 }
72 return bundle.Pass(); 73 return bundle.Pass();
73 } 74 }
74 75
76 PolicySource MockPolicyLoader::source() const {
Thiemo Nagel 2015/09/01 17:40:36 Remove.
fhorschig 2015/09/04 06:53:54 Done.
77 return POLICY_SOURCE_DEFAULT;
78 }
79
75 } // namespace 80 } // namespace
76 81
77 class AsyncPolicyProviderTest : public testing::Test { 82 class AsyncPolicyProviderTest : public testing::Test {
78 protected: 83 protected:
79 AsyncPolicyProviderTest(); 84 AsyncPolicyProviderTest();
80 ~AsyncPolicyProviderTest() override; 85 ~AsyncPolicyProviderTest() override;
81 86
82 void SetUp() override; 87 void SetUp() override;
83 void TearDown() override; 88 void TearDown() override;
84 89
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0); 222 EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(0);
218 provider_->Shutdown(); 223 provider_->Shutdown();
219 loop_.RunUntilIdle(); 224 loop_.RunUntilIdle();
220 Mock::VerifyAndClearExpectations(&observer); 225 Mock::VerifyAndClearExpectations(&observer);
221 226
222 provider_->RemoveObserver(&observer); 227 provider_->RemoveObserver(&observer);
223 provider_.reset(); 228 provider_.reset();
224 } 229 }
225 230
226 } // namespace policy 231 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698