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