| 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 virtual 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 virtual void TearDown() override { |
| 59 controller_.reset(); | 59 controller_.reset(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 virtual void OnModelChanged() OVERRIDE { | 62 virtual void OnModelChanged() override { |
| 63 model_changed_count_++; | 63 model_changed_count_++; |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual void OnItemsChanged(int start, int length) OVERRIDE { | 66 virtual void OnItemsChanged(int start, int length) override { |
| 67 items_changed_count_++; | 67 items_changed_count_++; |
| 68 } | 68 } |
| 69 | 69 |
| 70 virtual void OnItemsAdded(int start, int length) OVERRIDE { | 70 virtual void OnItemsAdded(int start, int length) override { |
| 71 added_count_++; | 71 added_count_++; |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual void OnItemsRemoved(int start, int length) OVERRIDE { | 74 virtual void OnItemsRemoved(int start, int length) override { |
| 75 removed_count_++; | 75 removed_count_++; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void VerifyChangeCount(int model_changed_count, int item_changed_count, | 78 void VerifyChangeCount(int model_changed_count, int item_changed_count, |
| 79 int added_count, int removed_count) { | 79 int added_count, int removed_count) { |
| 80 ASSERT_EQ(model_changed_count, model_changed_count_); | 80 ASSERT_EQ(model_changed_count, model_changed_count_); |
| 81 ASSERT_EQ(item_changed_count, items_changed_count_); | 81 ASSERT_EQ(item_changed_count, items_changed_count_); |
| 82 ASSERT_EQ(added_count, added_count_); | 82 ASSERT_EQ(added_count, added_count_); |
| 83 ASSERT_EQ(removed_count, removed_count_); | 83 ASSERT_EQ(removed_count, removed_count_); |
| 84 ClearChangeCount(); | 84 ClearChangeCount(); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 TemplateURL* turl = new TemplateURL(data); | 255 TemplateURL* turl = new TemplateURL(data); |
| 256 util()->model()->Add(turl); | 256 util()->model()->Add(turl); |
| 257 | 257 |
| 258 // Table model should have updated. | 258 // Table model should have updated. |
| 259 VerifyChangeCount(1, 0, 0, 0); | 259 VerifyChangeCount(1, 0, 0, 0); |
| 260 | 260 |
| 261 // And should contain the newly added TemplateURL. | 261 // And should contain the newly added TemplateURL. |
| 262 ASSERT_EQ(original_row_count + 1, table_model()->RowCount()); | 262 ASSERT_EQ(original_row_count + 1, table_model()->RowCount()); |
| 263 ASSERT_GE(table_model()->IndexOfTemplateURL(turl), 0); | 263 ASSERT_GE(table_model()->IndexOfTemplateURL(turl), 0); |
| 264 } | 264 } |
| OLD | NEW |