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

Side by Side Diff: chrome/browser/ui/search_engines/keyword_editor_controller_unittest.cc

Issue 376413002: Stop using TemplateURLServiceTestUtil to initialize TemplateURLServiceFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix TemplateURLServiceWithoutFallbackTest Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/strings/string16.h" 6 #include "base/strings/string16.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/search_engines/template_url_service_test_util.h" 9 #include "chrome/browser/search_engines/template_url_service_factory_test_util.h "
10 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" 10 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
11 #include "chrome/browser/ui/search_engines/template_url_table_model.h" 11 #include "chrome/browser/ui/search_engines/template_url_table_model.h"
12 #include "chrome/test/base/testing_pref_service_syncable.h"
12 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
13 #include "components/search_engines/template_url.h" 14 #include "components/search_engines/template_url.h"
14 #include "components/search_engines/template_url_service.h" 15 #include "components/search_engines/template_url_service.h"
16 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/base/models/table_model_observer.h" 18 #include "ui/base/models/table_model_observer.h"
17 19
18 using base::ASCIIToUTF16; 20 using base::ASCIIToUTF16;
19 21
20 static const base::string16 kA(ASCIIToUTF16("a")); 22 static const base::string16 kA(ASCIIToUTF16("a"));
21 static const base::string16 kA1(ASCIIToUTF16("a1")); 23 static const base::string16 kA1(ASCIIToUTF16("a1"));
22 static const base::string16 kB(ASCIIToUTF16("b")); 24 static const base::string16 kB(ASCIIToUTF16("b"));
23 static const base::string16 kB1(ASCIIToUTF16("b1")); 25 static const base::string16 kB1(ASCIIToUTF16("b1"));
24 26
25 // Base class for keyword editor tests. Creates a profile containing an 27 // Base class for keyword editor tests. Creates a profile containing an
26 // empty TemplateURLService. 28 // empty TemplateURLService.
27 class KeywordEditorControllerTest : public testing::Test, 29 class KeywordEditorControllerTest : public testing::Test,
28 public ui::TableModelObserver { 30 public ui::TableModelObserver {
29 public: 31 public:
30 KeywordEditorControllerTest() 32 KeywordEditorControllerTest()
31 : simulate_load_failure_(false), 33 : util_(&profile_),
34 simulate_load_failure_(false),
32 model_changed_count_(0), 35 model_changed_count_(0),
33 items_changed_count_(0), 36 items_changed_count_(0),
34 added_count_(0), 37 added_count_(0),
35 removed_count_(0) {} 38 removed_count_(0) {}
36 39
37 explicit KeywordEditorControllerTest(bool simulate_load_failure) 40 explicit KeywordEditorControllerTest(bool simulate_load_failure)
38 : simulate_load_failure_(simulate_load_failure), 41 : util_(&profile_),
42 simulate_load_failure_(simulate_load_failure),
39 model_changed_count_(0), 43 model_changed_count_(0),
40 items_changed_count_(0), 44 items_changed_count_(0),
41 added_count_(0), 45 added_count_(0),
42 removed_count_(0) {} 46 removed_count_(0) {}
43 47
44 virtual void SetUp() OVERRIDE { 48 virtual void SetUp() OVERRIDE {
45 util_.SetUp();
46
47 if (simulate_load_failure_) 49 if (simulate_load_failure_)
48 util_.model()->OnWebDataServiceRequestDone(0, NULL); 50 util_.model()->OnWebDataServiceRequestDone(0, NULL);
49 else 51 else
50 util_.ChangeModelToLoadState(); 52 util_.VerifyLoad();
51 53
52 controller_.reset(new KeywordEditorController(util_.profile())); 54 controller_.reset(new KeywordEditorController(&profile_));
53 controller_->table_model()->SetObserver(this); 55 controller_->table_model()->SetObserver(this);
54 } 56 }
55 57
56 virtual void TearDown() OVERRIDE { 58 virtual void TearDown() OVERRIDE {
57 controller_.reset(); 59 controller_.reset();
58 util_.TearDown();
59 } 60 }
60 61
61 virtual void OnModelChanged() OVERRIDE { 62 virtual void OnModelChanged() OVERRIDE {
62 model_changed_count_++; 63 model_changed_count_++;
63 } 64 }
64 65
65 virtual void OnItemsChanged(int start, int length) OVERRIDE { 66 virtual void OnItemsChanged(int start, int length) OVERRIDE {
66 items_changed_count_++; 67 items_changed_count_++;
67 } 68 }
68 69
(...skipping 26 matching lines...) Expand all
95 url, 96 url,
96 std::string(), 97 std::string(),
97 std::string(), 98 std::string(),
98 std::string(), 99 std::string(),
99 std::string(), 100 std::string(),
100 std::string()); 101 std::string());
101 } 102 }
102 103
103 TemplateURLTableModel* table_model() { return controller_->table_model(); } 104 TemplateURLTableModel* table_model() { return controller_->table_model(); }
104 KeywordEditorController* controller() { return controller_.get(); } 105 KeywordEditorController* controller() { return controller_.get(); }
105 const TemplateURLServiceTestUtil* util() const { return &util_; } 106 const TemplateURLServiceFactoryTestUtil* util() const { return &util_; }
106 107
107 int items_changed_count() const { return items_changed_count_; } 108 int items_changed_count() const { return items_changed_count_; }
108 int added_count() const { return added_count_; } 109 int added_count() const { return added_count_; }
109 int removed_count() const { return removed_count_; } 110 int removed_count() const { return removed_count_; }
110 111
111 private: 112 private:
113 content::TestBrowserThreadBundle thread_bundle_;
114 TestingProfile profile_;
112 scoped_ptr<KeywordEditorController> controller_; 115 scoped_ptr<KeywordEditorController> controller_;
113 TemplateURLServiceTestUtil util_; 116 TemplateURLServiceFactoryTestUtil util_;
114 bool simulate_load_failure_; 117 bool simulate_load_failure_;
115 118
116 int model_changed_count_; 119 int model_changed_count_;
117 int items_changed_count_; 120 int items_changed_count_;
118 int added_count_; 121 int added_count_;
119 int removed_count_; 122 int removed_count_;
120 }; 123 };
121 124
122 class KeywordEditorControllerNoWebDataTest 125 class KeywordEditorControllerNoWebDataTest
123 : public KeywordEditorControllerTest { 126 : public KeywordEditorControllerTest {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 TemplateURL* turl = new TemplateURL(data); 255 TemplateURL* turl = new TemplateURL(data);
253 util()->model()->Add(turl); 256 util()->model()->Add(turl);
254 257
255 // Table model should have updated. 258 // Table model should have updated.
256 VerifyChangeCount(1, 0, 0, 0); 259 VerifyChangeCount(1, 0, 0, 0);
257 260
258 // And should contain the newly added TemplateURL. 261 // And should contain the newly added TemplateURL.
259 ASSERT_EQ(original_row_count + 1, table_model()->RowCount()); 262 ASSERT_EQ(original_row_count + 1, table_model()->RowCount());
260 ASSERT_GE(table_model()->IndexOfTemplateURL(turl), 0); 263 ASSERT_GE(table_model()->IndexOfTemplateURL(turl), 0);
261 } 264 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/search_engine_data_type_controller_unittest.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698