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

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

Issue 5562002: Refactor FileBasedPolicyProvider, introduce AsynchronousPolicyProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review feedback 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_
6 #define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_
7 #pragma once
8
9 #include "base/message_loop.h"
10 #include "base/time.h"
Mattias Nissler (ping if slow) 2010/12/06 10:26:20 do you need this header?
danno 2010/12/06 14:05:12 Done.
11 #include "chrome/browser/browser_thread.h"
12 #include "chrome/browser/policy/asynchronous_policy_provider.h"
13 #include "chrome/browser/policy/configuration_policy_provider.h"
Mattias Nissler (ping if slow) 2010/12/06 10:26:20 isn't this one included in asynchronous_policy_pro
danno 2010/12/06 14:05:12 Done.
14 #include "chrome/browser/policy/mock_configuration_policy_store.h"
15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 namespace policy {
19
20 // A delegate for testing that can feed arbitrary information to the loader.
21 class ProviderDelegateMock : public AsynchronousPolicyProvider::Delegate {
22 public:
23 ProviderDelegateMock() : AsynchronousPolicyProvider::Delegate() {}
24 virtual ~ProviderDelegateMock() {}
25
26 MOCK_METHOD0(Load, DictionaryValue*());
27
28 private:
29 DISALLOW_COPY_AND_ASSIGN(ProviderDelegateMock);
30 };
31
32 class AsynchronousPolicyTestBase : public testing::Test {
33 public:
34 AsynchronousPolicyTestBase()
35 : run_pending_during_tear_down_(true),
36 ui_thread_(BrowserThread::UI, &loop_),
37 file_thread_(BrowserThread::FILE, &loop_) {}
38
39 virtual ~AsynchronousPolicyTestBase() {}
40
41 virtual void SetUp() {
42 delegate_.reset(new ProviderDelegateMock());
43 store_.reset(new MockConfigurationPolicyStore);
44 }
45
46 virtual void TearDown() {
47 provider_.reset(NULL);
48 if (run_pending_during_tear_down_)
49 loop_.RunAllPending();
50 }
51
52 protected:
53 MessageLoop loop_;
54 scoped_ptr<ConfigurationPolicyProvider> provider_;
Mattias Nissler (ping if slow) 2010/12/06 10:26:20 Seems like the provider_ is not really needed here
danno 2010/12/06 14:05:12 Done.
55
56 // The mocks that are used in the test must outlive the scope of the test
57 // because they still get accessed in the RunAllPending of the TearDown.
58 scoped_ptr<MockConfigurationPolicyStore> store_;
59 scoped_ptr<ProviderDelegateMock> delegate_;
60
61 private:
62 // True if a test guarantees that it's handled all tasks pending in the
63 // message loop and doesn't want RunAllPending run during TearDown.
64 bool run_pending_during_tear_down_;
Mattias Nissler (ping if slow) 2010/12/06 10:26:20 But there's no harm in always running it? So why n
danno 2010/12/06 14:05:12 This is dead code now. On 2010/12/06 10:26:20, Ma
65 BrowserThread ui_thread_;
66 BrowserThread file_thread_;
67
68 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyTestBase);
69 };
70
71 inline static void MessageLoopQuitNow() {
72 MessageLoop::current()->QuitNow();
Mattias Nissler (ping if slow) 2010/12/06 10:26:20 Do you really want to call QuitNow() instead of Qu
danno 2010/12/06 14:05:12 Yes. But this functionality isn't used anymore aft
73 }
74
75 } // namespace policy
76
77 #endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698