| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 util_.model()->Add(t_url); | 201 util_.model()->Add(t_url); |
| 202 return t_url; | 202 return t_url; |
| 203 } | 203 } |
| 204 | 204 |
| 205 // Actual tests --------------------------------------------------------------- | 205 // Actual tests --------------------------------------------------------------- |
| 206 | 206 |
| 207 TEST_F(SearchProviderInstallDataTest, GetInstallState) { | 207 TEST_F(SearchProviderInstallDataTest, GetInstallState) { |
| 208 // Set up the database. | 208 // Set up the database. |
| 209 util_.ChangeModelToLoadState(); | 209 util_.ChangeModelToLoadState(); |
| 210 std::string host = "www.unittest.com"; | 210 std::string host = "www.unittest.com"; |
| 211 AddNewTemplateURL("http://" + host + "/path", ASCIIToUTF16("unittest")); | 211 AddNewTemplateURL("http://" + host + "/path", base::ASCIIToUTF16("unittest")); |
| 212 | 212 |
| 213 // Wait for the changes to be saved. | 213 // Wait for the changes to be saved. |
| 214 base::RunLoop().RunUntilIdle(); | 214 base::RunLoop().RunUntilIdle(); |
| 215 | 215 |
| 216 // Verify the search providers install state (with no default set). | 216 // Verify the search providers install state (with no default set). |
| 217 TestGetInstallState test_get_install_state(install_data_); | 217 TestGetInstallState test_get_install_state(install_data_); |
| 218 test_get_install_state.RunTests(host, std::string()); | 218 test_get_install_state.RunTests(host, std::string()); |
| 219 | 219 |
| 220 // Set-up a default and try it all one more time. | 220 // Set-up a default and try it all one more time. |
| 221 std::string default_host = "www.mmm.com"; | 221 std::string default_host = "www.mmm.com"; |
| 222 TemplateURL* default_url = | 222 TemplateURL* default_url = |
| 223 AddNewTemplateURL("http://" + default_host + "/", ASCIIToUTF16("mmm")); | 223 AddNewTemplateURL("http://" + default_host + "/", |
| 224 base::ASCIIToUTF16("mmm")); |
| 224 util_.model()->SetDefaultSearchProvider(default_url); | 225 util_.model()->SetDefaultSearchProvider(default_url); |
| 225 test_get_install_state.RunTests(host, default_host); | 226 test_get_install_state.RunTests(host, default_host); |
| 226 } | 227 } |
| 227 | 228 |
| 228 TEST_F(SearchProviderInstallDataTest, ManagedDefaultSearch) { | 229 TEST_F(SearchProviderInstallDataTest, ManagedDefaultSearch) { |
| 229 // Set up the database. | 230 // Set up the database. |
| 230 util_.ChangeModelToLoadState(); | 231 util_.ChangeModelToLoadState(); |
| 231 std::string host = "www.unittest.com"; | 232 std::string host = "www.unittest.com"; |
| 232 AddNewTemplateURL("http://" + host + "/path", ASCIIToUTF16("unittest")); | 233 AddNewTemplateURL("http://" + host + "/path", base::ASCIIToUTF16("unittest")); |
| 233 | 234 |
| 234 // Set a managed preference that establishes a default search provider. | 235 // Set a managed preference that establishes a default search provider. |
| 235 std::string host2 = "www.managedtest.com"; | 236 std::string host2 = "www.managedtest.com"; |
| 236 std::string url2 = "http://" + host2 + "/p{searchTerms}"; | 237 std::string url2 = "http://" + host2 + "/p{searchTerms}"; |
| 237 SimulateDefaultSearchIsManaged(url2); | 238 SimulateDefaultSearchIsManaged(url2); |
| 238 EXPECT_TRUE(util_.model()->is_default_search_managed()); | 239 EXPECT_TRUE(util_.model()->is_default_search_managed()); |
| 239 | 240 |
| 240 // Wait for the changes to be saved. | 241 // Wait for the changes to be saved. |
| 241 base::RunLoop().RunUntilIdle(); | 242 base::RunLoop().RunUntilIdle(); |
| 242 | 243 |
| 243 // Verify the search providers install state. The default search should be | 244 // Verify the search providers install state. The default search should be |
| 244 // the managed one we previously set. | 245 // the managed one we previously set. |
| 245 TestGetInstallState test_get_install_state(install_data_); | 246 TestGetInstallState test_get_install_state(install_data_); |
| 246 test_get_install_state.RunTests(host, host2); | 247 test_get_install_state.RunTests(host, host2); |
| 247 } | 248 } |
| 248 | 249 |
| 249 TEST_F(SearchProviderInstallDataTest, GoogleBaseUrlChange) { | 250 TEST_F(SearchProviderInstallDataTest, GoogleBaseUrlChange) { |
| 250 TestGetInstallState test_get_install_state(install_data_); | 251 TestGetInstallState test_get_install_state(install_data_); |
| 251 | 252 |
| 252 // Set up the database. | 253 // Set up the database. |
| 253 util_.ChangeModelToLoadState(); | 254 util_.ChangeModelToLoadState(); |
| 254 std::string google_host = "w.com"; | 255 std::string google_host = "w.com"; |
| 255 util_.SetGoogleBaseURL(GURL("http://" + google_host + "/")); | 256 util_.SetGoogleBaseURL(GURL("http://" + google_host + "/")); |
| 256 // Wait for the I/O thread to process the update notification. | 257 // Wait for the I/O thread to process the update notification. |
| 257 base::RunLoop().RunUntilIdle(); | 258 base::RunLoop().RunUntilIdle(); |
| 258 | 259 |
| 259 AddNewTemplateURL("{google:baseURL}?q={searchTerms}", ASCIIToUTF16("t")); | 260 AddNewTemplateURL("{google:baseURL}?q={searchTerms}", |
| 261 base::ASCIIToUTF16("t")); |
| 260 TemplateURL* default_url = | 262 TemplateURL* default_url = |
| 261 AddNewTemplateURL("http://d.com/", ASCIIToUTF16("d")); | 263 AddNewTemplateURL("http://d.com/", base::ASCIIToUTF16("d")); |
| 262 util_.model()->SetDefaultSearchProvider(default_url); | 264 util_.model()->SetDefaultSearchProvider(default_url); |
| 263 | 265 |
| 264 // Wait for the changes to be saved. | 266 // Wait for the changes to be saved. |
| 265 base::RunLoop().RunUntilIdle(); | 267 base::RunLoop().RunUntilIdle(); |
| 266 | 268 |
| 267 // Verify the search providers install state (with no default set). | 269 // Verify the search providers install state (with no default set). |
| 268 test_get_install_state.RunTests(google_host, std::string()); | 270 test_get_install_state.RunTests(google_host, std::string()); |
| 269 | 271 |
| 270 // Change the Google base url. | 272 // Change the Google base url. |
| 271 google_host = "foo.com"; | 273 google_host = "foo.com"; |
| 272 util_.SetGoogleBaseURL(GURL("http://" + google_host + "/")); | 274 util_.SetGoogleBaseURL(GURL("http://" + google_host + "/")); |
| 273 // Wait for the I/O thread to process the update notification. | 275 // Wait for the I/O thread to process the update notification. |
| 274 base::RunLoop().RunUntilIdle(); | 276 base::RunLoop().RunUntilIdle(); |
| 275 | 277 |
| 276 // Verify that the change got picked up. | 278 // Verify that the change got picked up. |
| 277 test_get_install_state.RunTests(google_host, std::string()); | 279 test_get_install_state.RunTests(google_host, std::string()); |
| 278 } | 280 } |
| OLD | NEW |