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