Chromium Code Reviews| 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 "components/search_engines/template_url_service.h" | 5 #include "components/search_engines/template_url_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/task/cancelable_task_tracker.h" | 22 #include "base/task/cancelable_task_tracker.h" |
| 23 #include "base/test/simple_test_clock.h" | 23 #include "base/test/simple_test_clock.h" |
| 24 #include "base/threading/thread.h" | 24 #include "base/threading/thread.h" |
| 25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 26 #include "chrome/browser/history/history_service_factory.h" | 26 #include "chrome/browser/history/history_service_factory.h" |
| 27 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 27 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
| 28 #include "chrome/test/base/testing_profile.h" | 28 #include "chrome/test/base/testing_profile.h" |
| 29 #include "components/history/core/browser/history_service.h" | 29 #include "components/history/core/browser/history_service.h" |
| 30 #include "components/search_engines/keyword_web_data_service.h" | 30 #include "components/search_engines/keyword_web_data_service.h" |
| 31 #include "components/search_engines/search_engines_test_util.h" | |
| 31 #include "components/search_engines/search_host_to_urls_map.h" | 32 #include "components/search_engines/search_host_to_urls_map.h" |
| 32 #include "components/search_engines/search_terms_data.h" | 33 #include "components/search_engines/search_terms_data.h" |
| 33 #include "components/search_engines/template_url.h" | 34 #include "components/search_engines/template_url.h" |
| 34 #include "components/search_engines/template_url_prepopulate_data.h" | 35 #include "components/search_engines/template_url_prepopulate_data.h" |
| 35 #include "content/public/test/test_browser_thread_bundle.h" | 36 #include "content/public/test/test_browser_thread_bundle.h" |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
| 37 | 38 |
| 38 using base::ASCIIToUTF16; | 39 using base::ASCIIToUTF16; |
| 39 using base::Time; | 40 using base::Time; |
| 40 using base::TimeDelta; | 41 using base::TimeDelta; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 TemplateURL* t_url = model->Add(CreateKeywordWithDate( | 114 TemplateURL* t_url = model->Add(CreateKeywordWithDate( |
| 114 model, short_name, keyword, url, suggest_url, alternate_url, favicon_url, | 115 model, short_name, keyword, url, suggest_url, alternate_url, favicon_url, |
| 115 safe_for_autoreplace, 0, encodings, date_created, last_modified, | 116 safe_for_autoreplace, 0, encodings, date_created, last_modified, |
| 116 last_visited)); | 117 last_visited)); |
| 117 EXPECT_NE(0, t_url->id()); | 118 EXPECT_NE(0, t_url->id()); |
| 118 return t_url; | 119 return t_url; |
| 119 } | 120 } |
| 120 | 121 |
| 121 // Checks that the two TemplateURLs are similar. It does not check the id or | 122 // Checks that the two TemplateURLs are similar. It does not check the id or |
| 122 // any time-related fields. Neither pointer should be NULL. | 123 // any time-related fields. Neither pointer should be NULL. |
| 123 void ExpectSimilar(const TemplateURL* expected, const TemplateURL* actual) { | 124 void ExpectSimilar(const TemplateURL* expected, |
| 125 const TemplateURL* actual, | |
| 126 bool ignore_keyword = false) { | |
| 124 ASSERT_TRUE(expected != NULL); | 127 ASSERT_TRUE(expected != NULL); |
| 125 ASSERT_TRUE(actual != NULL); | 128 ASSERT_TRUE(actual != NULL); |
| 126 EXPECT_EQ(expected->short_name(), actual->short_name()); | 129 EXPECT_EQ(expected->short_name(), actual->short_name()); |
| 127 EXPECT_EQ(expected->keyword(), actual->keyword()); | 130 if (!ignore_keyword) { |
|
Peter Kasting
2017/01/25 22:31:23
Nit: No {}
Alexander Yashkin
2017/01/26 07:51:01
Done
| |
| 131 EXPECT_EQ(expected->keyword(), actual->keyword()); | |
| 132 } | |
| 128 EXPECT_EQ(expected->url(), actual->url()); | 133 EXPECT_EQ(expected->url(), actual->url()); |
| 129 EXPECT_EQ(expected->suggestions_url(), actual->suggestions_url()); | 134 EXPECT_EQ(expected->suggestions_url(), actual->suggestions_url()); |
| 130 EXPECT_EQ(expected->favicon_url(), actual->favicon_url()); | 135 EXPECT_EQ(expected->favicon_url(), actual->favicon_url()); |
| 131 EXPECT_EQ(expected->alternate_urls(), actual->alternate_urls()); | 136 EXPECT_EQ(expected->alternate_urls(), actual->alternate_urls()); |
| 132 EXPECT_EQ(expected->safe_for_autoreplace(), actual->safe_for_autoreplace()); | 137 EXPECT_EQ(expected->safe_for_autoreplace(), actual->safe_for_autoreplace()); |
| 133 EXPECT_EQ(expected->input_encodings(), actual->input_encodings()); | 138 EXPECT_EQ(expected->input_encodings(), actual->input_encodings()); |
| 134 EXPECT_EQ(expected->search_terms_replacement_key(), | 139 EXPECT_EQ(expected->search_terms_replacement_key(), |
| 135 actual->search_terms_replacement_key()); | 140 actual->search_terms_replacement_key()); |
| 136 } | 141 } |
| 137 | 142 |
| (...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1427 EXPECT_EQ(user_dse, model()->GetDefaultSearchProvider()); | 1432 EXPECT_EQ(user_dse, model()->GetDefaultSearchProvider()); |
| 1428 | 1433 |
| 1429 std::unique_ptr<TemplateURL> ext_dse = CreateKeywordWithDate( | 1434 std::unique_ptr<TemplateURL> ext_dse = CreateKeywordWithDate( |
| 1430 model(), "ext", "ext", "http://www.search.com/s?q={searchTerms}", | 1435 model(), "ext", "ext", "http://www.search.com/s?q={searchTerms}", |
| 1431 std::string(), std::string(), std::string(), true, kPrepopulatedId, | 1436 std::string(), std::string(), std::string(), true, kPrepopulatedId, |
| 1432 "UTF-8", Time(), Time(), Time(), | 1437 "UTF-8", Time(), Time(), Time(), |
| 1433 TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); | 1438 TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); |
| 1434 std::unique_ptr<TemplateURL::AssociatedExtensionInfo> extension_info( | 1439 std::unique_ptr<TemplateURL::AssociatedExtensionInfo> extension_info( |
| 1435 new TemplateURL::AssociatedExtensionInfo("ext")); | 1440 new TemplateURL::AssociatedExtensionInfo("ext")); |
| 1436 extension_info->wants_to_be_default_engine = true; | 1441 extension_info->wants_to_be_default_engine = true; |
| 1437 TemplateURL* ext_dse_ptr = model()->AddExtensionControlledTURL( | 1442 TemplateURL* ext_dse_ptr = test_util()->AddExtensionControlledTURL( |
| 1438 std::move(ext_dse), std::move(extension_info)); | 1443 std::move(ext_dse), std::move(extension_info)); |
| 1439 EXPECT_EQ(ext_dse_ptr, model()->GetDefaultSearchProvider()); | 1444 EXPECT_EQ(ext_dse_ptr, model()->GetDefaultSearchProvider()); |
| 1440 | 1445 |
| 1441 model()->RemoveExtensionControlledTURL( | 1446 test_util()->RemoveExtensionControlledTURL("ext"); |
| 1442 "ext", TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); | |
| 1443 ExpectSimilar(user_dse, model()->GetDefaultSearchProvider()); | 1447 ExpectSimilar(user_dse, model()->GetDefaultSearchProvider()); |
| 1444 } | 1448 } |
| 1445 | 1449 |
| 1446 TEST_F(TemplateURLServiceTest, ExtensionEnginesNotPersist) { | 1450 TEST_F(TemplateURLServiceTest, DefaultExtensionEnginePersist) { |
| 1447 test_util()->VerifyLoad(); | 1451 test_util()->VerifyLoad(); |
| 1448 // Add third-party default search engine. | 1452 // Add third-party default search engine. |
| 1449 TemplateURL* user_dse = AddKeywordWithDate( | 1453 TemplateURL* user_dse = AddKeywordWithDate( |
| 1450 "user", "user", "http://www.goo.com/s?q={searchTerms}", std::string(), | 1454 "user", "user", "http://www.goo.com/s?q={searchTerms}", std::string(), |
| 1451 std::string(), std::string(), true, "UTF-8", Time(), Time(), Time()); | 1455 std::string(), std::string(), true, "UTF-8", Time(), Time(), Time()); |
| 1452 model()->SetUserSelectedDefaultSearchProvider(user_dse); | 1456 model()->SetUserSelectedDefaultSearchProvider(user_dse); |
| 1453 EXPECT_EQ(user_dse, model()->GetDefaultSearchProvider()); | 1457 EXPECT_EQ(user_dse, model()->GetDefaultSearchProvider()); |
| 1454 | 1458 |
| 1459 // Create non-default extension search engine. | |
| 1455 std::unique_ptr<TemplateURL> ext_dse = CreateKeywordWithDate( | 1460 std::unique_ptr<TemplateURL> ext_dse = CreateKeywordWithDate( |
| 1456 model(), "ext1", "ext1", "http://www.ext1.com/s?q={searchTerms}", | 1461 model(), "ext1", "ext1", "http://www.ext1.com/s?q={searchTerms}", |
| 1457 std::string(), std::string(), std::string(), true, 0, "UTF-8", Time(), | 1462 std::string(), std::string(), std::string(), true, 0, "UTF-8", Time(), |
| 1458 Time(), Time(), TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); | 1463 Time(), Time(), TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); |
| 1459 std::unique_ptr<TemplateURL::AssociatedExtensionInfo> extension_info( | 1464 std::unique_ptr<TemplateURL::AssociatedExtensionInfo> extension_info( |
| 1460 new TemplateURL::AssociatedExtensionInfo("ext1")); | 1465 new TemplateURL::AssociatedExtensionInfo("ext1")); |
| 1461 extension_info->wants_to_be_default_engine = false; | 1466 extension_info->wants_to_be_default_engine = false; |
| 1462 model()->AddExtensionControlledTURL(std::move(ext_dse), | 1467 |
| 1463 std::move(extension_info)); | 1468 test_util()->AddExtensionControlledTURL(std::move(ext_dse), |
| 1469 std::move(extension_info)); | |
| 1464 EXPECT_EQ(user_dse, model()->GetDefaultSearchProvider()); | 1470 EXPECT_EQ(user_dse, model()->GetDefaultSearchProvider()); |
| 1465 | 1471 |
| 1472 // Create default extension search engine. | |
| 1466 ext_dse = CreateKeywordWithDate( | 1473 ext_dse = CreateKeywordWithDate( |
| 1467 model(), "ext2", "ext2", "http://www.ext2.com/s?q={searchTerms}", | 1474 model(), "ext2", "ext2", "http://www.ext2.com/s?q={searchTerms}", |
| 1468 std::string(), std::string(), std::string(), true, kPrepopulatedId, | 1475 std::string(), std::string(), std::string(), true, kPrepopulatedId, |
| 1469 "UTF-8", Time(), Time(), Time(), | 1476 "UTF-8", Time(), Time(), Time(), |
| 1470 TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); | 1477 TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); |
| 1471 extension_info.reset(new TemplateURL::AssociatedExtensionInfo("ext2")); | 1478 extension_info.reset(new TemplateURL::AssociatedExtensionInfo("ext2")); |
| 1472 extension_info->wants_to_be_default_engine = true; | 1479 extension_info->wants_to_be_default_engine = true; |
| 1473 TemplateURL* ext_dse_ptr = model()->AddExtensionControlledTURL( | 1480 |
| 1481 auto cloned_ext_dse = base::MakeUnique<TemplateURL>(ext_dse->data()); | |
| 1482 TemplateURL* ext_dse_ptr = test_util()->AddExtensionControlledTURL( | |
| 1474 std::move(ext_dse), std::move(extension_info)); | 1483 std::move(ext_dse), std::move(extension_info)); |
| 1475 EXPECT_EQ(ext_dse_ptr, model()->GetDefaultSearchProvider()); | 1484 EXPECT_EQ(ext_dse_ptr, model()->GetDefaultSearchProvider()); |
| 1476 | 1485 |
| 1477 test_util()->ResetModel(true); | 1486 // A default search engine set by an extension must be persisted across |
| 1478 user_dse = model()->GetTemplateURLForKeyword(ASCIIToUTF16("user")); | 1487 // browser restarts, until the extension is unloaded/disabled. |
| 1479 ExpectSimilar(user_dse, model()->GetDefaultSearchProvider()); | 1488 test_util()->ResetModel(false); |
| 1489 EXPECT_TRUE(model()->GetTemplateURLForKeyword(ASCIIToUTF16("ext2"))); | |
| 1490 ExpectSimilar(cloned_ext_dse.get(), model()->GetDefaultSearchProvider()); | |
| 1491 | |
| 1492 // Non-default extension engines are not persisted across restarts. | |
| 1480 EXPECT_FALSE(model()->GetTemplateURLForKeyword(ASCIIToUTF16("ext1"))); | 1493 EXPECT_FALSE(model()->GetTemplateURLForKeyword(ASCIIToUTF16("ext1"))); |
| 1481 EXPECT_FALSE(model()->GetTemplateURLForKeyword(ASCIIToUTF16("ext2"))); | 1494 } |
| 1495 | |
| 1496 TEST_F(TemplateURLServiceTest, DefaultExtensionEnginePersistsBeforeLoad) { | |
| 1497 // Chrome will load the extension system before the TemplateURLService, so | |
| 1498 // extensions controlling the default search engine may be registered before | |
| 1499 // the service has loaded. | |
| 1500 std::unique_ptr<TemplateURL> ext_dse = CreateKeywordWithDate( | |
| 1501 model(), "ext2", "ext2", "http://www.ext2.com/s?q={searchTerms}", | |
| 1502 std::string(), std::string(), std::string(), true, kPrepopulatedId, | |
| 1503 "UTF-8", Time(), Time(), Time(), | |
| 1504 TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); | |
| 1505 auto extension_info = | |
| 1506 base::MakeUnique<TemplateURL::AssociatedExtensionInfo>("ext2"); | |
| 1507 extension_info->wants_to_be_default_engine = true; | |
| 1508 | |
| 1509 auto cloned_ext_dse = base::MakeUnique<TemplateURL>(ext_dse->data()); | |
| 1510 test_util()->AddExtensionControlledTURL(std::move(ext_dse), | |
| 1511 std::move(extension_info)); | |
| 1512 | |
| 1513 // Default search engine from extension must be persisted between browser | |
| 1514 // restarts, and should be available before the TemplateURLService is loaded. | |
| 1515 EXPECT_TRUE(model()->GetTemplateURLForKeyword(ASCIIToUTF16("ext2"))); | |
| 1516 ExpectSimilar(cloned_ext_dse.get(), model()->GetDefaultSearchProvider()); | |
| 1517 | |
| 1518 // Check extension DSE is the same after service load. | |
| 1519 test_util()->VerifyLoad(); | |
| 1520 ExpectSimilar(cloned_ext_dse.get(), model()->GetDefaultSearchProvider()); | |
| 1521 } | |
| 1522 | |
| 1523 // Check that extension engine and prepopulated engine with same keywords are | |
| 1524 // handled corrected. | |
| 1525 TEST_F(TemplateURLServiceTest, DefaultExtensionEngineAndPrepopulated) { | |
| 1526 // Add default extension engine. | |
| 1527 auto ext_data = GenerateDummyTemplateURLData("ext2"); | |
| 1528 ext_data->safe_for_autoreplace = false; | |
| 1529 auto ext_dse = base::MakeUnique<TemplateURL>( | |
| 1530 *ext_data, TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); | |
| 1531 auto extension_info = | |
| 1532 base::MakeUnique<TemplateURL::AssociatedExtensionInfo>("ext2"); | |
| 1533 extension_info->wants_to_be_default_engine = true; | |
| 1534 | |
| 1535 auto cloned_ext_dse = base::MakeUnique<TemplateURL>(ext_dse->data()); | |
| 1536 test_util()->AddExtensionControlledTURL(std::move(ext_dse), | |
| 1537 std::move(extension_info)); | |
| 1538 | |
| 1539 // Add prepopulated engine with same keyword as extension. | |
| 1540 model()->Add( | |
| 1541 base::MakeUnique<TemplateURL>(*GenerateDummyTemplateURLData("ext2"))); | |
| 1542 // Wait for any saves to finish. | |
| 1543 base::RunLoop().RunUntilIdle(); | |
| 1544 | |
| 1545 test_util()->VerifyLoad(); | |
| 1546 // Check extension DSE is set as default. Due to keywords conflict with | |
| 1547 // prepopulated engine its keyword changed. | |
| 1548 EXPECT_TRUE(model()->IsExtensionControlledDefaultSearch()); | |
| 1549 ExpectSimilar(cloned_ext_dse.get(), model()->GetDefaultSearchProvider(), | |
| 1550 true); | |
|
Peter Kasting
2017/01/25 22:31:23
Should we be checking as to which engine's keyword
Alexander Yashkin
2017/01/26 07:51:01
Done
| |
| 1551 } | |
| 1552 | |
| 1553 // Check that two extensions with same engine handled corrected. | |
|
Peter Kasting
2017/01/25 22:31:23
What parts of the engines being "the same" are rel
Alexander Yashkin
2017/01/26 07:51:01
The keyword conflict is relevant. Changed comments
| |
| 1554 TEST_F(TemplateURLServiceTest, TwoExtensionsWithSameEngine) { | |
| 1555 // Add default extension engine. | |
| 1556 auto ext_data = GenerateDummyTemplateURLData("extension"); | |
| 1557 ext_data->safe_for_autoreplace = false; | |
| 1558 auto ext_dse = base::MakeUnique<TemplateURL>( | |
| 1559 *ext_data, TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); | |
| 1560 auto extension_info = | |
| 1561 base::MakeUnique<TemplateURL::AssociatedExtensionInfo>("extension_id1"); | |
| 1562 extension_info->wants_to_be_default_engine = true; | |
| 1563 | |
| 1564 auto cloned_ext_dse = base::MakeUnique<TemplateURL>(ext_dse->data()); | |
| 1565 test_util()->AddExtensionControlledTURL(std::move(ext_dse), | |
| 1566 std::move(extension_info)); | |
| 1567 | |
| 1568 // Add non default extension with same engine. This action will change | |
| 1569 // previous extension keyword due to conflict. | |
| 1570 ext_data = GenerateDummyTemplateURLData("extension"); | |
| 1571 ext_data->safe_for_autoreplace = false; | |
| 1572 ext_dse = base::MakeUnique<TemplateURL>( | |
| 1573 *ext_data, TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); | |
| 1574 extension_info = | |
| 1575 base::MakeUnique<TemplateURL::AssociatedExtensionInfo>("extension_id2"); | |
| 1576 extension_info->wants_to_be_default_engine = false; | |
| 1577 | |
| 1578 test_util()->AddExtensionControlledTURL(std::move(ext_dse), | |
| 1579 std::move(extension_info)); | |
| 1580 // Wait for any saves to finish. | |
| 1581 base::RunLoop().RunUntilIdle(); | |
| 1582 | |
| 1583 test_util()->VerifyLoad(); | |
| 1584 // Check that extension DSE is set as default. Due to keywords conflict with | |
| 1585 // prepopulated engine its keyword changed. | |
| 1586 auto current_dse = model()->GetDefaultSearchProvider(); | |
| 1587 EXPECT_TRUE(model()->IsExtensionControlledDefaultSearch()); | |
| 1588 ExpectSimilar(cloned_ext_dse.get(), current_dse, true); | |
| 1589 EXPECT_EQ("extension_id1", | |
| 1590 current_dse->GetExtensionInfoForTesting()->extension_id); | |
| 1482 } | 1591 } |
| 1483 | 1592 |
| 1484 TEST_F(TemplateURLServiceTest, ExtensionEngineVsPolicy) { | 1593 TEST_F(TemplateURLServiceTest, ExtensionEngineVsPolicy) { |
| 1485 // Set a managed preference that establishes a default search provider. | 1594 // Set a managed preference that establishes a default search provider. |
| 1486 std::unique_ptr<TemplateURLData> managed = CreateTestSearchEngine(); | 1595 std::unique_ptr<TemplateURLData> managed = CreateTestSearchEngine(); |
| 1487 SetManagedDefaultSearchPreferences(*managed, true, test_util()->profile()); | 1596 SetManagedDefaultSearchPreferences(*managed, true, test_util()->profile()); |
| 1488 test_util()->VerifyLoad(); | 1597 test_util()->VerifyLoad(); |
| 1489 // Verify that the default manager we are getting is the managed one. | 1598 // Verify that the default manager we are getting is the managed one. |
| 1490 auto expected_managed_default = base::MakeUnique<TemplateURL>(*managed); | 1599 auto expected_managed_default = base::MakeUnique<TemplateURL>(*managed); |
| 1491 EXPECT_TRUE(model()->is_default_search_managed()); | 1600 EXPECT_TRUE(model()->is_default_search_managed()); |
| 1492 const TemplateURL* actual_managed_default = | 1601 const TemplateURL* actual_managed_default = |
| 1493 model()->GetDefaultSearchProvider(); | 1602 model()->GetDefaultSearchProvider(); |
| 1494 ExpectSimilar(expected_managed_default.get(), actual_managed_default); | 1603 ExpectSimilar(expected_managed_default.get(), actual_managed_default); |
| 1495 | 1604 |
| 1496 std::unique_ptr<TemplateURL> ext_dse = CreateKeywordWithDate( | 1605 std::unique_ptr<TemplateURL> ext_dse = CreateKeywordWithDate( |
| 1497 model(), "ext1", "ext1", "http://www.ext1.com/s?q={searchTerms}", | 1606 model(), "ext1", "ext1", "http://www.ext1.com/s?q={searchTerms}", |
| 1498 std::string(), std::string(), std::string(), true, kPrepopulatedId, | 1607 std::string(), std::string(), std::string(), true, kPrepopulatedId, |
| 1499 "UTF-8", Time(), Time(), Time(), | 1608 "UTF-8", Time(), Time(), Time(), |
| 1500 TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); | 1609 TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION); |
| 1501 auto extension_info = | 1610 auto extension_info = |
| 1502 base::MakeUnique<TemplateURL::AssociatedExtensionInfo>("ext1"); | 1611 base::MakeUnique<TemplateURL::AssociatedExtensionInfo>("ext1"); |
| 1503 extension_info->wants_to_be_default_engine = true; | 1612 extension_info->wants_to_be_default_engine = true; |
| 1504 TemplateURL* ext_dse_ptr = model()->AddExtensionControlledTURL( | 1613 TemplateURL* ext_dse_ptr = test_util()->AddExtensionControlledTURL( |
| 1505 std::move(ext_dse), std::move(extension_info)); | 1614 std::move(ext_dse), std::move(extension_info)); |
| 1506 EXPECT_EQ(ext_dse_ptr, | 1615 EXPECT_EQ(ext_dse_ptr, |
| 1507 model()->GetTemplateURLForKeyword(ASCIIToUTF16("ext1"))); | 1616 model()->GetTemplateURLForKeyword(ASCIIToUTF16("ext1"))); |
| 1508 EXPECT_TRUE(model()->is_default_search_managed()); | 1617 EXPECT_TRUE(model()->is_default_search_managed()); |
| 1509 actual_managed_default = model()->GetDefaultSearchProvider(); | 1618 actual_managed_default = model()->GetDefaultSearchProvider(); |
| 1510 ExpectSimilar(expected_managed_default.get(), actual_managed_default); | 1619 ExpectSimilar(expected_managed_default.get(), actual_managed_default); |
| 1511 } | 1620 } |
| 1512 | 1621 |
| 1513 TEST_F(TemplateURLServiceTest, LastVisitedTimeUpdate) { | 1622 TEST_F(TemplateURLServiceTest, LastVisitedTimeUpdate) { |
| 1514 test_util()->VerifyLoad(); | 1623 test_util()->VerifyLoad(); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 1542 TemplateURL* update_url = | 1651 TemplateURL* update_url = |
| 1543 model()->GetTemplateURLForKeyword(ASCIIToUTF16("engine_keyword")); | 1652 model()->GetTemplateURLForKeyword(ASCIIToUTF16("engine_keyword")); |
| 1544 const base::Time update_last_modified = update_url->last_modified(); | 1653 const base::Time update_last_modified = update_url->last_modified(); |
| 1545 model()->SetUserSelectedDefaultSearchProvider(update_url); | 1654 model()->SetUserSelectedDefaultSearchProvider(update_url); |
| 1546 TemplateURL* reloaded_url = | 1655 TemplateURL* reloaded_url = |
| 1547 model()->GetTemplateURLForKeyword(ASCIIToUTF16("engine_keyword")); | 1656 model()->GetTemplateURLForKeyword(ASCIIToUTF16("engine_keyword")); |
| 1548 const base::Time reloaded_last_modified = reloaded_url->last_modified(); | 1657 const base::Time reloaded_last_modified = reloaded_url->last_modified(); |
| 1549 EXPECT_NE(original_last_modified, reloaded_last_modified); | 1658 EXPECT_NE(original_last_modified, reloaded_last_modified); |
| 1550 EXPECT_EQ(update_last_modified, reloaded_last_modified); | 1659 EXPECT_EQ(update_last_modified, reloaded_last_modified); |
| 1551 } | 1660 } |
| OLD | NEW |