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 "chrome/browser/policy/asynchronous_policy_provider.h" 11 #include "content/browser/browser_thread.h" 12 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gtest/include/gtest/gtest.h" 14 15 namespace policy { 16 17 class MockConfigurationPolicyStore; 18 19 // A delegate for testing that can feed arbitrary information to the loader. 20 class ProviderDelegateMock : public AsynchronousPolicyProvider::Delegate { 21 public: 22 ProviderDelegateMock(); 23 virtual ~ProviderDelegateMock(); 24 25 MOCK_METHOD0(Load, DictionaryValue*()); 26 27 private: 28 DISALLOW_COPY_AND_ASSIGN(ProviderDelegateMock); 29 }; 30 31 class AsynchronousPolicyTestBase : public testing::Test { 32 public: 33 AsynchronousPolicyTestBase(); 34 virtual ~AsynchronousPolicyTestBase(); 35 36 // testing::Test: 37 virtual void SetUp(); 38 virtual void TearDown(); 39 40 protected: 41 MessageLoop loop_; 42 43 // The mocks that are used in the test must outlive the scope of the test 44 // because they still get accessed in the RunAllPending of the TearDown. 45 scoped_ptr<MockConfigurationPolicyStore> store_; 46 scoped_ptr<ProviderDelegateMock> delegate_; 47 48 private: 49 BrowserThread ui_thread_; 50 BrowserThread file_thread_; 51 52 DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyTestBase); 53 }; 54 55 } // namespace policy 56 57 #endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_ 58