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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/drive/test_util.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_registry_simple.h"
11 #include "base/prefs/testing_pref_service.h"
12 #include "base/run_loop.h"
13 #include "base/threading/sequenced_worker_pool.h"
14 #include "chrome/browser/chromeos/drive/drive.pb.h"
15 #include "chrome/common/pref_names.h"
16 #include "content/public/browser/browser_thread.h"
24 // This class is used to monitor if any task is posted to a message loop.
25 class TaskObserver
: public base::MessageLoop::TaskObserver
{
27 TaskObserver() : posted_(false) {}
28 virtual ~TaskObserver() {}
30 // MessageLoop::TaskObserver overrides.
31 virtual void WillProcessTask(const base::PendingTask
& pending_task
) OVERRIDE
{
33 virtual void DidProcessTask(const base::PendingTask
& pending_task
) OVERRIDE
{
37 // Returns true if any task was posted.
38 bool posted() const { return posted_
; }
42 DISALLOW_COPY_AND_ASSIGN(TaskObserver
);
47 void RunBlockingPoolTask() {
49 content::BrowserThread::GetBlockingPool()->FlushForTesting();
51 TaskObserver task_observer
;
52 base::MessageLoop::current()->AddTaskObserver(&task_observer
);
53 base::RunLoop().RunUntilIdle();
54 base::MessageLoop::current()->RemoveTaskObserver(&task_observer
);
55 if (!task_observer
.posted())
60 void RegisterDrivePrefs(PrefRegistrySimple
* pref_registry
) {
61 pref_registry
->RegisterBooleanPref(
64 pref_registry
->RegisterBooleanPref(
65 prefs::kDisableDriveOverCellular
,
67 pref_registry
->RegisterBooleanPref(
68 prefs::kDisableDriveHostedFiles
,
72 FakeNetworkChangeNotifier::FakeNetworkChangeNotifier()
73 : type_(CONNECTION_WIFI
) {
76 void FakeNetworkChangeNotifier::SetConnectionType(ConnectionType type
) {
78 NotifyObserversOfConnectionTypeChange();
81 net::NetworkChangeNotifier::ConnectionType
82 FakeNetworkChangeNotifier::GetCurrentConnectionType() const {
86 } // namespace test_util