| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string16.h" | 5 #include "base/string16.h" | 
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" | 
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" | 
| 8 #include "chrome/browser/search_engines/template_url.h" | 8 #include "chrome/browser/search_engines/template_url.h" | 
| 9 #include "chrome/browser/search_engines/template_url_service.h" | 9 #include "chrome/browser/search_engines/template_url_service.h" | 
| 10 #include "chrome/browser/search_engines/template_url_service_factory.h" | 10 #include "chrome/browser/search_engines/template_url_service_factory.h" | 
| 11 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" | 11 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" | 
| 12 #include "chrome/browser/ui/search_engines/template_url_table_model.h" | 12 #include "chrome/browser/ui/search_engines/template_url_table_model.h" | 
|  | 13 #include "chrome/common/chrome_notification_types.h" | 
| 13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" | 
| 14 #include "chrome/test/testing_pref_service.h" | 15 #include "chrome/test/testing_pref_service.h" | 
| 15 #include "chrome/test/testing_profile.h" | 16 #include "chrome/test/testing_profile.h" | 
| 16 #include "content/common/notification_details.h" | 17 #include "content/common/notification_details.h" | 
| 17 #include "content/common/notification_source.h" | 18 #include "content/common/notification_source.h" | 
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" | 
| 19 #include "ui/base/models/table_model_observer.h" | 20 #include "ui/base/models/table_model_observer.h" | 
| 20 | 21 | 
| 21 static const string16 kA(ASCIIToUTF16("a")); | 22 static const string16 kA(ASCIIToUTF16("a")); | 
| 22 static const string16 kA1(ASCIIToUTF16("a1")); | 23 static const string16 kA1(ASCIIToUTF16("a1")); | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 76         Value::CreateStringValue(url)); | 77         Value::CreateStringValue(url)); | 
| 77     service->SetManagedPref( | 78     service->SetManagedPref( | 
| 78         prefs::kDefaultSearchProviderName, | 79         prefs::kDefaultSearchProviderName, | 
| 79         Value::CreateStringValue("managed")); | 80         Value::CreateStringValue("managed")); | 
| 80     // Clear the IDs that are not specified via policy. | 81     // Clear the IDs that are not specified via policy. | 
| 81     service->SetManagedPref( | 82     service->SetManagedPref( | 
| 82         prefs::kDefaultSearchProviderID, new StringValue("")); | 83         prefs::kDefaultSearchProviderID, new StringValue("")); | 
| 83     service->SetManagedPref( | 84     service->SetManagedPref( | 
| 84         prefs::kDefaultSearchProviderPrepopulateID, new StringValue("")); | 85         prefs::kDefaultSearchProviderPrepopulateID, new StringValue("")); | 
| 85     model_->Observe( | 86     model_->Observe( | 
| 86         NotificationType::PREF_CHANGED, | 87         chrome::NOTIFICATION_PREF_CHANGED, | 
| 87         Source<PrefService>(profile_->GetTestingPrefService()), | 88         Source<PrefService>(profile_->GetTestingPrefService()), | 
| 88         Details<std::string>(NULL)); | 89         Details<std::string>(NULL)); | 
| 89   } | 90   } | 
| 90 | 91 | 
| 91   TemplateURLTableModel* table_model() const { | 92   TemplateURLTableModel* table_model() const { | 
| 92     return controller_->table_model(); | 93     return controller_->table_model(); | 
| 93   } | 94   } | 
| 94 | 95 | 
| 95  protected: | 96  protected: | 
| 96   MessageLoopForUI message_loop_; | 97   MessageLoopForUI message_loop_; | 
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 250   turl->set_short_name(ASCIIToUTF16("b")); | 251   turl->set_short_name(ASCIIToUTF16("b")); | 
| 251   model_->Add(turl); | 252   model_->Add(turl); | 
| 252 | 253 | 
| 253   // Table model should have updated. | 254   // Table model should have updated. | 
| 254   VerifyChangeCount(1, 0, 0, 0); | 255   VerifyChangeCount(1, 0, 0, 0); | 
| 255 | 256 | 
| 256   // And should contain the newly added TemplateURL. | 257   // And should contain the newly added TemplateURL. | 
| 257   ASSERT_EQ(1, table_model()->RowCount()); | 258   ASSERT_EQ(1, table_model()->RowCount()); | 
| 258   ASSERT_EQ(0, table_model()->IndexOfTemplateURL(turl)); | 259   ASSERT_EQ(0, table_model()->IndexOfTemplateURL(turl)); | 
| 259 } | 260 } | 
| OLD | NEW | 
|---|