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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/asynchronous_policy_test_base.h
diff --git a/chrome/browser/policy/asynchronous_policy_test_base.h b/chrome/browser/policy/asynchronous_policy_test_base.h
new file mode 100644
index 0000000000000000000000000000000000000000..8eb7f04f414da0f3920c923bde88eac1162026a7
--- /dev/null
+++ b/chrome/browser/policy/asynchronous_policy_test_base.h
@@ -0,0 +1,77 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_
+#define CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_
+#pragma once
+
+#include "base/message_loop.h"
+#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.
+#include "chrome/browser/browser_thread.h"
+#include "chrome/browser/policy/asynchronous_policy_provider.h"
+#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.
+#include "chrome/browser/policy/mock_configuration_policy_store.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace policy {
+
+// A delegate for testing that can feed arbitrary information to the loader.
+class ProviderDelegateMock : public AsynchronousPolicyProvider::Delegate {
+ public:
+ ProviderDelegateMock() : AsynchronousPolicyProvider::Delegate() {}
+ virtual ~ProviderDelegateMock() {}
+
+ MOCK_METHOD0(Load, DictionaryValue*());
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ProviderDelegateMock);
+};
+
+class AsynchronousPolicyTestBase : public testing::Test {
+ public:
+ AsynchronousPolicyTestBase()
+ : run_pending_during_tear_down_(true),
+ ui_thread_(BrowserThread::UI, &loop_),
+ file_thread_(BrowserThread::FILE, &loop_) {}
+
+ virtual ~AsynchronousPolicyTestBase() {}
+
+ virtual void SetUp() {
+ delegate_.reset(new ProviderDelegateMock());
+ store_.reset(new MockConfigurationPolicyStore);
+ }
+
+ virtual void TearDown() {
+ provider_.reset(NULL);
+ if (run_pending_during_tear_down_)
+ loop_.RunAllPending();
+ }
+
+ protected:
+ MessageLoop loop_;
+ 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.
+
+ // The mocks that are used in the test must outlive the scope of the test
+ // because they still get accessed in the RunAllPending of the TearDown.
+ scoped_ptr<MockConfigurationPolicyStore> store_;
+ scoped_ptr<ProviderDelegateMock> delegate_;
+
+ private:
+ // True if a test guarantees that it's handled all tasks pending in the
+ // message loop and doesn't want RunAllPending run during TearDown.
+ 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
+ BrowserThread ui_thread_;
+ BrowserThread file_thread_;
+
+ DISALLOW_COPY_AND_ASSIGN(AsynchronousPolicyTestBase);
+};
+
+inline static void MessageLoopQuitNow() {
+ 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
+}
+
+} // namespace policy
+
+#endif // CHROME_BROWSER_POLICY_ASYNCHRONOUS_POLICY_TEST_BASE_H_

Powered by Google App Engine
This is Rietveld 408576698