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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/string16.h" | 6 #include "base/string16.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/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.h" | 9 #include "chrome/browser/search_engines/template_url.h" |
10 #include "chrome/browser/search_engines/template_url_service.h" | 10 #include "chrome/browser/search_engines/template_url_service.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 void ClearChangeCount() { | 64 void ClearChangeCount() { |
65 model_changed_count_ = items_changed_count_ = added_count_ = | 65 model_changed_count_ = items_changed_count_ = added_count_ = |
66 removed_count_ = 0; | 66 removed_count_ = 0; |
67 } | 67 } |
68 | 68 |
69 void SimulateDefaultSearchIsManaged(const std::string& url) { | 69 void SimulateDefaultSearchIsManaged(const std::string& url) { |
70 ASSERT_FALSE(url.empty()); | 70 ASSERT_FALSE(url.empty()); |
71 TestingPrefService* service = profile_->GetTestingPrefService(); | 71 TestingPrefService* service = profile_->GetTestingPrefService(); |
72 service->SetManagedPref(prefs::kDefaultSearchProviderEnabled, | 72 service->SetManagedPref(prefs::kDefaultSearchProviderEnabled, |
73 Value::CreateBooleanValue(true)); | 73 new base::FundamentalValue(true)); |
74 service->SetManagedPref(prefs::kDefaultSearchProviderSearchURL, | 74 service->SetManagedPref(prefs::kDefaultSearchProviderSearchURL, |
75 Value::CreateStringValue(url)); | 75 new base::StringValue(url)); |
76 service->SetManagedPref(prefs::kDefaultSearchProviderName, | 76 service->SetManagedPref(prefs::kDefaultSearchProviderName, |
77 Value::CreateStringValue("managed")); | 77 new base::StringValue("managed")); |
78 // Clear the IDs that are not specified via policy. | 78 // Clear the IDs that are not specified via policy. |
79 service->SetManagedPref(prefs::kDefaultSearchProviderID, | 79 service->SetManagedPref(prefs::kDefaultSearchProviderID, |
80 new StringValue(std::string())); | 80 new base::StringValue(std::string())); |
81 service->SetManagedPref(prefs::kDefaultSearchProviderPrepopulateID, | 81 service->SetManagedPref(prefs::kDefaultSearchProviderPrepopulateID, |
82 new StringValue(std::string())); | 82 new base::StringValue(std::string())); |
83 model_->Observe(chrome::NOTIFICATION_DEFAULT_SEARCH_POLICY_CHANGED, | 83 model_->Observe(chrome::NOTIFICATION_DEFAULT_SEARCH_POLICY_CHANGED, |
84 content::NotificationService::AllSources(), | 84 content::NotificationService::AllSources(), |
85 content::NotificationService::NoDetails()); | 85 content::NotificationService::NoDetails()); |
86 } | 86 } |
87 | 87 |
88 TemplateURLTableModel* table_model() const { | 88 TemplateURLTableModel* table_model() const { |
89 return controller_->table_model(); | 89 return controller_->table_model(); |
90 } | 90 } |
91 | 91 |
92 protected: | 92 protected: |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 TemplateURL* turl = new TemplateURL(profile_.get(), data); | 247 TemplateURL* turl = new TemplateURL(profile_.get(), data); |
248 model_->Add(turl); | 248 model_->Add(turl); |
249 | 249 |
250 // Table model should have updated. | 250 // Table model should have updated. |
251 VerifyChangeCount(1, 0, 0, 0); | 251 VerifyChangeCount(1, 0, 0, 0); |
252 | 252 |
253 // And should contain the newly added TemplateURL. | 253 // And should contain the newly added TemplateURL. |
254 ASSERT_EQ(1, table_model()->RowCount()); | 254 ASSERT_EQ(1, table_model()->RowCount()); |
255 ASSERT_EQ(0, table_model()->IndexOfTemplateURL(turl)); | 255 ASSERT_EQ(0, table_model()->IndexOfTemplateURL(turl)); |
256 } | 256 } |
OLD | NEW |