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

Side by Side Diff: chrome/browser/profile_resetter/profile_resetter_unittest.cc

Issue 15572002: Implemented 'Reset Search engines' feature. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Android compilation error Created 7 years, 7 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 (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/callback.h" 8 #include "base/callback.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/search_engines/template_url_service_test_util.h"
11 #include "chrome/test/base/testing_profile.h"
10 #include "content/public/test/test_browser_thread.h" 12 #include "content/public/test/test_browser_thread.h"
11 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
12 14
13 namespace { 15 namespace {
14 16
15 class MockObject { 17 class MockObject {
16 public: 18 public:
17 MOCK_METHOD0(Callback, void(void)); 19 MOCK_METHOD0(Callback, void(void));
18 }; 20 };
19 21
20 class ProfileResetterTest : public testing::Test { 22 class ProfileResetterTest : public testing::Test {
21 public: 23 public:
22 ProfileResetterTest() 24 ProfileResetterTest() {
23 : ui_thread_(content::BrowserThread::UI, &message_loop_), 25 }
24 resetter_(NULL) {} 26
battre 2013/05/22 14:03:37 I think that we should actually go in the opposite
vasilii 2013/05/22 18:54:08 I modified the tests in another way.
27 // testing::Test
28 virtual void SetUp();
29 virtual void TearDown();
25 30
26 ~ProfileResetterTest() {} 31 ~ProfileResetterTest() {}
27 32
28 private:
29 base::MessageLoopForUI message_loop_;
30 content::TestBrowserThread ui_thread_;
31
32 protected: 33 protected:
33 testing::StrictMock<MockObject> mock_object_; 34 testing::StrictMock<MockObject> mock_object_;
34 ProfileResetter resetter_; 35 TemplateURLServiceTestUtil test_util_;
36 scoped_ptr<ProfileResetter> resetter_;
37
38 DISALLOW_COPY_AND_ASSIGN(ProfileResetterTest);
35 }; 39 };
36 40
41 void ProfileResetterTest::SetUp() {
42 test_util_.SetUp();
43 resetter_.reset(new ProfileResetter(test_util_.profile()));
44 }
45
46 void ProfileResetterTest::TearDown() {
47 test_util_.TearDown();
48 }
49
37 TEST_F(ProfileResetterTest, ResetDefaultSearchEngine) { 50 TEST_F(ProfileResetterTest, ResetDefaultSearchEngine) {
38 EXPECT_CALL(mock_object_, Callback()); 51 EXPECT_CALL(mock_object_, Callback());
39 resetter_.Reset( 52 test_util_.VerifyLoad();
53 resetter_->Reset(
40 ProfileResetter::DEFAULT_SEARCH_ENGINE, 54 ProfileResetter::DEFAULT_SEARCH_ENGINE,
41 ProfileResetter::DISABLE_EXTENSIONS, 55 ProfileResetter::DISABLE_EXTENSIONS,
42 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_))); 56 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_)));
43 } 57 }
44 58
45 TEST_F(ProfileResetterTest, ResetHomepage) { 59 TEST_F(ProfileResetterTest, ResetHomepage) {
46 EXPECT_CALL(mock_object_, Callback()); 60 EXPECT_CALL(mock_object_, Callback());
47 resetter_.Reset( 61 resetter_->Reset(
48 ProfileResetter::HOMEPAGE, 62 ProfileResetter::HOMEPAGE,
49 ProfileResetter::DISABLE_EXTENSIONS, 63 ProfileResetter::DISABLE_EXTENSIONS,
50 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_))); 64 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_)));
51 } 65 }
52 66
53 TEST_F(ProfileResetterTest, ResetContentSettings) { 67 TEST_F(ProfileResetterTest, ResetContentSettings) {
54 EXPECT_CALL(mock_object_, Callback()); 68 EXPECT_CALL(mock_object_, Callback());
55 resetter_.Reset( 69 resetter_->Reset(
56 ProfileResetter::CONTENT_SETTINGS, 70 ProfileResetter::CONTENT_SETTINGS,
57 ProfileResetter::DISABLE_EXTENSIONS, 71 ProfileResetter::DISABLE_EXTENSIONS,
58 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_))); 72 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_)));
59 } 73 }
60 74
61 TEST_F(ProfileResetterTest, ResetCookiesAndSiteData) { 75 TEST_F(ProfileResetterTest, ResetCookiesAndSiteData) {
62 EXPECT_CALL(mock_object_, Callback()); 76 EXPECT_CALL(mock_object_, Callback());
63 resetter_.Reset( 77 resetter_->Reset(
64 ProfileResetter::COOKIES_AND_SITE_DATA, 78 ProfileResetter::COOKIES_AND_SITE_DATA,
65 ProfileResetter::DISABLE_EXTENSIONS, 79 ProfileResetter::DISABLE_EXTENSIONS,
66 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_))); 80 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_)));
67 } 81 }
68 82
69 TEST_F(ProfileResetterTest, ResetExtensionsByDisabling) { 83 TEST_F(ProfileResetterTest, ResetExtensionsByDisabling) {
70 EXPECT_CALL(mock_object_, Callback()); 84 EXPECT_CALL(mock_object_, Callback());
71 resetter_.Reset( 85 resetter_->Reset(
72 ProfileResetter::EXTENSIONS, 86 ProfileResetter::EXTENSIONS,
73 ProfileResetter::DISABLE_EXTENSIONS, 87 ProfileResetter::DISABLE_EXTENSIONS,
74 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_))); 88 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_)));
75 } 89 }
76 90
77 TEST_F(ProfileResetterTest, ResetExtensionsByUninstalling) { 91 TEST_F(ProfileResetterTest, ResetExtensionsByUninstalling) {
78 EXPECT_CALL(mock_object_, Callback()); 92 EXPECT_CALL(mock_object_, Callback());
79 resetter_.Reset( 93 resetter_->Reset(
80 ProfileResetter::EXTENSIONS, 94 ProfileResetter::EXTENSIONS,
81 ProfileResetter::UNINSTALL_EXTENSIONS, 95 ProfileResetter::UNINSTALL_EXTENSIONS,
82 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_))); 96 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_)));
83 } 97 }
84 98
85 TEST_F(ProfileResetterTest, ResetExtensionsAll) { 99 TEST_F(ProfileResetterTest, ResetExtensionsAll) {
86 // mock_object_ is a StrictMock, so we verify that it is called only once. 100 // mock_object_ is a StrictMock, so we verify that it is called only once.
87 EXPECT_CALL(mock_object_, Callback()); 101 EXPECT_CALL(mock_object_, Callback());
88 resetter_.Reset( 102 test_util_.VerifyLoad();
103 resetter_->Reset(
89 ProfileResetter::ALL, 104 ProfileResetter::ALL,
90 ProfileResetter::UNINSTALL_EXTENSIONS, 105 ProfileResetter::UNINSTALL_EXTENSIONS,
91 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_))); 106 base::Bind(&MockObject::Callback, base::Unretained(&mock_object_)));
92 } 107 }
93 108
94 } // namespace 109 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698