| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.h" | 5 #include "chrome/browser/profile_resetter/profile_resetter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/prefs/session_startup_pref.h" | 9 #include "chrome/browser/prefs/session_startup_pref.h" |
| 10 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 10 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 private: | 32 private: |
| 33 MOCK_METHOD0(Callback, void(void)); | 33 MOCK_METHOD0(Callback, void(void)); |
| 34 | 34 |
| 35 scoped_refptr<content::MessageLoopRunner> runner_; | 35 scoped_refptr<content::MessageLoopRunner> runner_; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 class ProfileResetterTest : public testing::Test { | 38 class ProfileResetterTest : public testing::Test { |
| 39 protected: | 39 protected: |
| 40 ProfileResetterTest(); | 40 ProfileResetterTest(); |
| 41 ~ProfileResetterTest(); | 41 ~ProfileResetterTest(); |
| 42 |
| 42 // testing::Test: | 43 // testing::Test: |
| 43 virtual void SetUp() OVERRIDE; | 44 virtual void SetUp() OVERRIDE; |
| 44 virtual void TearDown() OVERRIDE; | 45 virtual void TearDown() OVERRIDE; |
| 45 | 46 |
| 46 testing::StrictMock<MockObject> mock_object_; | 47 testing::StrictMock<MockObject> mock_object_; |
| 47 TemplateURLServiceTestUtil test_util_; | 48 TemplateURLServiceTestUtil test_util_; |
| 48 scoped_ptr<ProfileResetter> resetter_; | 49 scoped_ptr<ProfileResetter> resetter_; |
| 49 | 50 |
| 50 DISALLOW_COPY_AND_ASSIGN(ProfileResetterTest); | 51 DISALLOW_COPY_AND_ASSIGN(ProfileResetterTest); |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 ProfileResetterTest::ProfileResetterTest() {} | 54 ProfileResetterTest::ProfileResetterTest() {} |
| 54 | 55 |
| 55 ProfileResetterTest::~ProfileResetterTest() {} | 56 ProfileResetterTest::~ProfileResetterTest() {} |
| 56 | 57 |
| 57 void ProfileResetterTest::SetUp() { | 58 void ProfileResetterTest::SetUp() { |
| 58 test_util_.SetUp(); | 59 test_util_.SetUp(); |
| 59 resetter_.reset(new ProfileResetter(test_util_.profile())); | 60 resetter_.reset(new ProfileResetter(test_util_.profile())); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void ProfileResetterTest::TearDown() { | 63 void ProfileResetterTest::TearDown() { |
| 63 test_util_.TearDown(); | 64 test_util_.TearDown(); |
| 64 } | 65 } |
| 65 | 66 |
| 66 TEST_F(ProfileResetterTest, ResetDefaultSearchEngine) { | 67 TEST_F(ProfileResetterTest, ResetDefaultSearchEngine) { |
| 67 test_util_.VerifyLoad(); | |
| 68 resetter_->Reset( | 68 resetter_->Reset( |
| 69 ProfileResetter::DEFAULT_SEARCH_ENGINE, | 69 ProfileResetter::DEFAULT_SEARCH_ENGINE, |
| 70 ProfileResetter::DISABLE_EXTENSIONS, | 70 ProfileResetter::DISABLE_EXTENSIONS, |
| 71 base::Bind(&MockObject::StopLoop, base::Unretained(&mock_object_))); | 71 base::Bind(&MockObject::StopLoop, base::Unretained(&mock_object_))); |
| 72 mock_object_.RunLoop(); | 72 mock_object_.RunLoop(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 TEST_F(ProfileResetterTest, ResetHomepage) { | 75 TEST_F(ProfileResetterTest, ResetHomepage) { |
| 76 PrefService* prefs = test_util_.profile()->GetPrefs(); | 76 PrefService* prefs = test_util_.profile()->GetPrefs(); |
| 77 DCHECK(prefs); | 77 DCHECK(prefs); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 base::Bind(&MockObject::StopLoop, base::Unretained(&mock_object_))); | 137 base::Bind(&MockObject::StopLoop, base::Unretained(&mock_object_))); |
| 138 mock_object_.RunLoop(); | 138 mock_object_.RunLoop(); |
| 139 | 139 |
| 140 startup_pref = SessionStartupPref::GetStartupPref(prefs); | 140 startup_pref = SessionStartupPref::GetStartupPref(prefs); |
| 141 EXPECT_EQ(SessionStartupPref::GetDefaultStartupType(), startup_pref.type); | 141 EXPECT_EQ(SessionStartupPref::GetDefaultStartupType(), startup_pref.type); |
| 142 EXPECT_EQ(std::vector<GURL>(), startup_pref.urls); | 142 EXPECT_EQ(std::vector<GURL>(), startup_pref.urls); |
| 143 } | 143 } |
| 144 | 144 |
| 145 TEST_F(ProfileResetterTest, ResetExtensionsAll) { | 145 TEST_F(ProfileResetterTest, ResetExtensionsAll) { |
| 146 // mock_object_ is a StrictMock, so we verify that it is called only once. | 146 // mock_object_ is a StrictMock, so we verify that it is called only once. |
| 147 test_util_.VerifyLoad(); | |
| 148 resetter_->Reset( | 147 resetter_->Reset( |
| 149 ProfileResetter::ALL, | 148 ProfileResetter::ALL, |
| 150 ProfileResetter::UNINSTALL_EXTENSIONS, | 149 ProfileResetter::UNINSTALL_EXTENSIONS, |
| 151 base::Bind(&MockObject::StopLoop, base::Unretained(&mock_object_))); | 150 base::Bind(&MockObject::StopLoop, base::Unretained(&mock_object_))); |
| 152 mock_object_.RunLoop(); | 151 mock_object_.RunLoop(); |
| 153 } | 152 } |
| 154 | 153 |
| 155 } // namespace | 154 } // namespace |
| OLD | NEW |