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

Side by Side Diff: chrome/browser/sync/backup_rollback_controller_unittest.cc

Issue 1143343005: chrome/browser: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/sync/backup_rollback_controller.h" 5 #include "chrome/browser/sync/backup_rollback_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/location.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/single_thread_task_runner.h"
11 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" 12 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h"
12 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
13 #include "components/sync_driver/sync_prefs.h" 14 #include "components/sync_driver/sync_prefs.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 using ::testing::Return; 18 using ::testing::Return;
18 19
19 namespace { 20 namespace {
20 21
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 controller_.reset(new browser_sync::BackupRollbackController( 62 controller_.reset(new browser_sync::BackupRollbackController(
62 &fake_prefs_, &signin_wrapper_, 63 &fake_prefs_, &signin_wrapper_,
63 base::Bind(&BackupRollbackControllerTest::ControllerCallback, 64 base::Bind(&BackupRollbackControllerTest::ControllerCallback,
64 base::Unretained(this), true), 65 base::Unretained(this), true),
65 base::Bind(&BackupRollbackControllerTest::ControllerCallback, 66 base::Bind(&BackupRollbackControllerTest::ControllerCallback,
66 base::Unretained(this), false))); 67 base::Unretained(this), false)));
67 } 68 }
68 69
69 void PumpLoop() { 70 void PumpLoop() {
70 base::RunLoop run_loop; 71 base::RunLoop run_loop;
71 loop_.PostTask(FROM_HERE, run_loop.QuitClosure()); 72 loop_.task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure());
72 run_loop.Run(); 73 run_loop.Run();
73 } 74 }
74 75
75 MockSigninManagerWrapper signin_wrapper_; 76 MockSigninManagerWrapper signin_wrapper_;
76 FakeSyncPrefs fake_prefs_; 77 FakeSyncPrefs fake_prefs_;
77 scoped_ptr<browser_sync::BackupRollbackController> controller_; 78 scoped_ptr<browser_sync::BackupRollbackController> controller_;
78 bool backup_started_; 79 bool backup_started_;
79 bool rollback_started_; 80 bool rollback_started_;
80 base::MessageLoop loop_; 81 base::MessageLoop loop_;
81 }; 82 };
82 83
83 TEST_F(BackupRollbackControllerTest, StartBackup) { 84 TEST_F(BackupRollbackControllerTest, StartBackup) {
84 EXPECT_TRUE(controller_->StartBackup()); 85 EXPECT_TRUE(controller_->StartBackup());
85 PumpLoop(); 86 PumpLoop();
86 EXPECT_TRUE(backup_started_); 87 EXPECT_TRUE(backup_started_);
87 } 88 }
88 89
89 TEST_F(BackupRollbackControllerTest, NoBackupIfDisabled) { 90 TEST_F(BackupRollbackControllerTest, NoBackupIfDisabled) {
90 base::CommandLine::ForCurrentProcess()->AppendSwitch( 91 base::CommandLine::ForCurrentProcess()->AppendSwitch(
91 switches::kSyncDisableBackup); 92 switches::kSyncDisableBackup);
92 93
93 base::RunLoop run_loop; 94 base::RunLoop run_loop;
94 EXPECT_FALSE(controller_->StartBackup()); 95 EXPECT_FALSE(controller_->StartBackup());
95 loop_.PostTask(FROM_HERE, run_loop.QuitClosure()); 96 loop_.task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure());
96 run_loop.Run(); 97 run_loop.Run();
97 EXPECT_FALSE(backup_started_); 98 EXPECT_FALSE(backup_started_);
98 } 99 }
99 100
100 TEST_F(BackupRollbackControllerTest, StartRollback) { 101 TEST_F(BackupRollbackControllerTest, StartRollback) {
101 fake_prefs_.SetRemainingRollbackTries(1); 102 fake_prefs_.SetRemainingRollbackTries(1);
102 103
103 EXPECT_TRUE(controller_->StartRollback()); 104 EXPECT_TRUE(controller_->StartRollback());
104 PumpLoop(); 105 PumpLoop();
105 EXPECT_TRUE(rollback_started_); 106 EXPECT_TRUE(rollback_started_);
(...skipping 30 matching lines...) Expand all
136 EXPECT_EQ(0, fake_prefs_.GetRemainingRollbackTries()); 137 EXPECT_EQ(0, fake_prefs_.GetRemainingRollbackTries());
137 138
138 PumpLoop(); 139 PumpLoop();
139 EXPECT_FALSE(rollback_started_); 140 EXPECT_FALSE(rollback_started_);
140 } 141 }
141 142
142 #endif 143 #endif
143 144
144 } // anonymous namespace 145 } // anonymous namespace
145 146
OLDNEW
« no previous file with comments | « chrome/browser/sync/backup_rollback_controller.cc ('k') | chrome/browser/sync/glue/bookmark_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698