| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profile_resetter/profile_resetter_test_base.h" | 5 #include "chrome/browser/profile_resetter/profile_resetter_test_base.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" | 10 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" |
| 10 | 11 |
| 11 ProfileResetterMockObject::ProfileResetterMockObject() {} | 12 ProfileResetterMockObject::ProfileResetterMockObject() {} |
| 12 | 13 |
| 13 ProfileResetterMockObject::~ProfileResetterMockObject() {} | 14 ProfileResetterMockObject::~ProfileResetterMockObject() {} |
| 14 | 15 |
| 15 void ProfileResetterMockObject::RunLoop() { | 16 void ProfileResetterMockObject::RunLoop() { |
| 16 EXPECT_CALL(*this, Callback()); | 17 EXPECT_CALL(*this, Callback()); |
| 17 runner_ = new content::MessageLoopRunner; | 18 runner_ = new content::MessageLoopRunner; |
| 18 runner_->Run(); | 19 runner_->Run(); |
| 19 runner_ = NULL; | 20 runner_ = NULL; |
| 20 } | 21 } |
| 21 | 22 |
| 22 void ProfileResetterMockObject::StopLoop() { | 23 void ProfileResetterMockObject::StopLoop() { |
| 23 DCHECK(runner_.get()); | 24 DCHECK(runner_.get()); |
| 24 Callback(); | 25 Callback(); |
| 25 runner_->Quit(); | 26 runner_->Quit(); |
| 26 } | 27 } |
| 27 | 28 |
| 28 ProfileResetterTestBase::ProfileResetterTestBase() {} | 29 ProfileResetterTestBase::ProfileResetterTestBase() {} |
| 29 | 30 |
| 30 ProfileResetterTestBase::~ProfileResetterTestBase() {} | 31 ProfileResetterTestBase::~ProfileResetterTestBase() {} |
| 31 | 32 |
| 32 void ProfileResetterTestBase::ResetAndWait( | 33 void ProfileResetterTestBase::ResetAndWait( |
| 33 ProfileResetter::ResettableFlags resettable_flags) { | 34 ProfileResetter::ResettableFlags resettable_flags) { |
| 34 scoped_ptr<BrandcodedDefaultSettings> master_settings( | 35 scoped_ptr<BrandcodedDefaultSettings> master_settings( |
| 35 new BrandcodedDefaultSettings); | 36 new BrandcodedDefaultSettings); |
| 36 resetter_->Reset(resettable_flags, | 37 resetter_->Reset(resettable_flags, std::move(master_settings), |
| 37 master_settings.Pass(), | |
| 38 base::Bind(&ProfileResetterMockObject::StopLoop, | 38 base::Bind(&ProfileResetterMockObject::StopLoop, |
| 39 base::Unretained(&mock_object_))); | 39 base::Unretained(&mock_object_))); |
| 40 mock_object_.RunLoop(); | 40 mock_object_.RunLoop(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void ProfileResetterTestBase::ResetAndWait( | 43 void ProfileResetterTestBase::ResetAndWait( |
| 44 ProfileResetter::ResettableFlags resettable_flags, | 44 ProfileResetter::ResettableFlags resettable_flags, |
| 45 const std::string& prefs) { | 45 const std::string& prefs) { |
| 46 scoped_ptr<BrandcodedDefaultSettings> master_settings( | 46 scoped_ptr<BrandcodedDefaultSettings> master_settings( |
| 47 new BrandcodedDefaultSettings(prefs)); | 47 new BrandcodedDefaultSettings(prefs)); |
| 48 resetter_->Reset(resettable_flags, | 48 resetter_->Reset(resettable_flags, std::move(master_settings), |
| 49 master_settings.Pass(), | |
| 50 base::Bind(&ProfileResetterMockObject::StopLoop, | 49 base::Bind(&ProfileResetterMockObject::StopLoop, |
| 51 base::Unretained(&mock_object_))); | 50 base::Unretained(&mock_object_))); |
| 52 mock_object_.RunLoop(); | 51 mock_object_.RunLoop(); |
| 53 } | 52 } |
| OLD | NEW |