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