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

Side by Side Diff: chrome/browser/policy/asynchronous_policy_test_base.h

Issue 10384145: Removed ConfigurationPolicyProvider::Provide(). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased Created 8 years, 7 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 (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 #ifndef CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_ 5 #ifndef CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_
6 #define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_ 6 #define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "chrome/browser/policy/asynchronous_policy_provider.h" 11 #include "chrome/browser/policy/asynchronous_policy_provider.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/test/test_browser_thread.h" 13 #include "content/test/test_browser_thread.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace policy { 17 namespace policy {
18 18
19 class PolicyMap; 19 class PolicyBundle;
20 20
21 // A delegate for testing that can feed arbitrary information to the loader. 21 // A delegate for testing that can feed arbitrary information to the loader.
22 class ProviderDelegateMock : public AsynchronousPolicyProvider::Delegate { 22 class ProviderDelegateMock : public AsynchronousPolicyProvider::Delegate {
23 public: 23 public:
24 ProviderDelegateMock(); 24 ProviderDelegateMock();
25 virtual ~ProviderDelegateMock(); 25 virtual ~ProviderDelegateMock();
26 26
27 MOCK_METHOD0(Load, PolicyMap*()); 27 // Load() returns a scoped_ptr<PolicyBundle> but it can't be mocked because
28 // scoped_ptr is moveable but not copyable. This override forwards the
29 // call to MockLoad() which returns a PolicyBundle*, and returns a copy
30 // wrapped in a passed scoped_ptr.
31 virtual scoped_ptr<PolicyBundle> Load() OVERRIDE {
32 scoped_ptr<PolicyBundle> bundle;
33 PolicyBundle* loaded = MockLoad();
34 if (loaded) {
35 bundle.reset(new PolicyBundle());
36 bundle->CopyFrom(*loaded);
37 }
38 return bundle.Pass();
39 }
40
41 MOCK_METHOD0(MockLoad, PolicyBundle*());
28 42
29 private: 43 private:
30 DISALLOW_COPY_AND_ASSIGN(ProviderDelegateMock); 44 DISALLOW_COPY_AND_ASSIGN(ProviderDelegateMock);
31 }; 45 };
32 46
33 class AsynchronousPolicyTestBase : public testing::Test { 47 class AsynchronousPolicyTestBase : public testing::Test {
34 public: 48 public:
35 AsynchronousPolicyTestBase(); 49 AsynchronousPolicyTestBase();
36 virtual ~AsynchronousPolicyTestBase(); 50 virtual ~AsynchronousPolicyTestBase();
37 51
38 // testing::Test: 52 // testing::Test:
39 virtual void TearDown() OVERRIDE; 53 virtual void TearDown() OVERRIDE;
40 54
41 protected: 55 protected:
42 // Create an actual IO loop (needed by FilePathWatcher). 56 // Create an actual IO loop (needed by FilePathWatcher).
43 MessageLoopForIO loop_; 57 MessageLoopForIO loop_;
44 58
45 private: 59 private:
46 content::TestBrowserThread ui_thread_; 60 content::TestBrowserThread ui_thread_;
47 content::TestBrowserThread file_thread_; 61 content::TestBrowserThread file_thread_;
48 62
49 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyTestBase); 63 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyTestBase);
50 }; 64 };
51 65
52 } // namespace policy 66 } // namespace policy
53 67
54 #endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_ 68 #endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698