OLD | NEW |
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_factory_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" |
(...skipping 27 matching lines...) Expand all Loading... |
38 removed_count_(0) {} | 38 removed_count_(0) {} |
39 | 39 |
40 explicit KeywordEditorControllerTest(bool simulate_load_failure) | 40 explicit KeywordEditorControllerTest(bool simulate_load_failure) |
41 : util_(&profile_), | 41 : util_(&profile_), |
42 simulate_load_failure_(simulate_load_failure), | 42 simulate_load_failure_(simulate_load_failure), |
43 model_changed_count_(0), | 43 model_changed_count_(0), |
44 items_changed_count_(0), | 44 items_changed_count_(0), |
45 added_count_(0), | 45 added_count_(0), |
46 removed_count_(0) {} | 46 removed_count_(0) {} |
47 | 47 |
48 virtual void SetUp() override { | 48 void SetUp() override { |
49 if (simulate_load_failure_) | 49 if (simulate_load_failure_) |
50 util_.model()->OnWebDataServiceRequestDone(0, NULL); | 50 util_.model()->OnWebDataServiceRequestDone(0, NULL); |
51 else | 51 else |
52 util_.VerifyLoad(); | 52 util_.VerifyLoad(); |
53 | 53 |
54 controller_.reset(new KeywordEditorController(&profile_)); | 54 controller_.reset(new KeywordEditorController(&profile_)); |
55 controller_->table_model()->SetObserver(this); | 55 controller_->table_model()->SetObserver(this); |
56 } | 56 } |
57 | 57 |
58 virtual void TearDown() override { | 58 void TearDown() override { controller_.reset(); } |
59 controller_.reset(); | |
60 } | |
61 | 59 |
62 void OnModelChanged() override { model_changed_count_++; } | 60 void OnModelChanged() override { model_changed_count_++; } |
63 | 61 |
64 void OnItemsChanged(int start, int length) override { | 62 void OnItemsChanged(int start, int length) override { |
65 items_changed_count_++; | 63 items_changed_count_++; |
66 } | 64 } |
67 | 65 |
68 void OnItemsAdded(int start, int length) override { added_count_++; } | 66 void OnItemsAdded(int start, int length) override { added_count_++; } |
69 | 67 |
70 void OnItemsRemoved(int start, int length) override { removed_count_++; } | 68 void OnItemsRemoved(int start, int length) override { removed_count_++; } |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 TemplateURL* turl = new TemplateURL(data); | 247 TemplateURL* turl = new TemplateURL(data); |
250 util()->model()->Add(turl); | 248 util()->model()->Add(turl); |
251 | 249 |
252 // Table model should have updated. | 250 // Table model should have updated. |
253 VerifyChangeCount(1, 0, 0, 0); | 251 VerifyChangeCount(1, 0, 0, 0); |
254 | 252 |
255 // And should contain the newly added TemplateURL. | 253 // And should contain the newly added TemplateURL. |
256 ASSERT_EQ(original_row_count + 1, table_model()->RowCount()); | 254 ASSERT_EQ(original_row_count + 1, table_model()->RowCount()); |
257 ASSERT_GE(table_model()->IndexOfTemplateURL(turl), 0); | 255 ASSERT_GE(table_model()->IndexOfTemplateURL(turl), 0); |
258 } | 256 } |
OLD | NEW |