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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 | 991 |
992 // Add a visit that matches the url of the keyword. | 992 // Add a visit that matches the url of the keyword. |
993 HistoryService* history = | 993 HistoryService* history = |
994 HistoryServiceFactory::GetForProfile(test_util()->profile(), | 994 HistoryServiceFactory::GetForProfile(test_util()->profile(), |
995 Profile::EXPLICIT_ACCESS); | 995 Profile::EXPLICIT_ACCESS); |
996 history->AddPage( | 996 history->AddPage( |
997 GURL(t_url->url_ref().ReplaceSearchTerms( | 997 GURL(t_url->url_ref().ReplaceSearchTerms( |
998 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("blah")), | 998 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("blah")), |
999 search_terms_data())), | 999 search_terms_data())), |
1000 base::Time::Now(), NULL, 0, GURL(), history::RedirectList(), | 1000 base::Time::Now(), NULL, 0, GURL(), history::RedirectList(), |
1001 content::PAGE_TRANSITION_KEYWORD, history::SOURCE_BROWSED, false); | 1001 ui::PAGE_TRANSITION_KEYWORD, history::SOURCE_BROWSED, false); |
1002 | 1002 |
1003 // Wait for history to finish processing the request. | 1003 // Wait for history to finish processing the request. |
1004 test_util()->profile()->BlockUntilHistoryProcessesPendingRequests(); | 1004 test_util()->profile()->BlockUntilHistoryProcessesPendingRequests(); |
1005 | 1005 |
1006 // Query history for the generated url. | 1006 // Query history for the generated url. |
1007 base::CancelableTaskTracker tracker; | 1007 base::CancelableTaskTracker tracker; |
1008 QueryHistoryCallbackImpl callback; | 1008 QueryHistoryCallbackImpl callback; |
1009 history->QueryURL(GURL("http://keyword"), | 1009 history->QueryURL(GURL("http://keyword"), |
1010 true, | 1010 true, |
1011 base::Bind(&QueryHistoryCallbackImpl::Callback, | 1011 base::Bind(&QueryHistoryCallbackImpl::Callback, |
1012 base::Unretained(&callback)), | 1012 base::Unretained(&callback)), |
1013 &tracker); | 1013 &tracker); |
1014 | 1014 |
1015 // Wait for the request to be processed. | 1015 // Wait for the request to be processed. |
1016 test_util()->profile()->BlockUntilHistoryProcessesPendingRequests(); | 1016 test_util()->profile()->BlockUntilHistoryProcessesPendingRequests(); |
1017 | 1017 |
1018 // And make sure the url and visit were added. | 1018 // And make sure the url and visit were added. |
1019 EXPECT_TRUE(callback.success); | 1019 EXPECT_TRUE(callback.success); |
1020 EXPECT_NE(0, callback.row.id()); | 1020 EXPECT_NE(0, callback.row.id()); |
1021 ASSERT_EQ(1U, callback.visits.size()); | 1021 ASSERT_EQ(1U, callback.visits.size()); |
1022 EXPECT_EQ(content::PAGE_TRANSITION_KEYWORD_GENERATED, | 1022 EXPECT_EQ(ui::PAGE_TRANSITION_KEYWORD_GENERATED, |
1023 content::PageTransitionStripQualifier(callback.visits[0].transition)); | 1023 ui::PageTransitionStripQualifier(callback.visits[0].transition)); |
1024 } | 1024 } |
1025 | 1025 |
1026 // Make sure that the load routine deletes prepopulated engines that no longer | 1026 // Make sure that the load routine deletes prepopulated engines that no longer |
1027 // exist in the prepopulate data. | 1027 // exist in the prepopulate data. |
1028 TEST_F(TemplateURLServiceTest, LoadDeletesUnusedProvider) { | 1028 TEST_F(TemplateURLServiceTest, LoadDeletesUnusedProvider) { |
1029 // Create a preloaded template url. Add it to a loaded model and wait for the | 1029 // Create a preloaded template url. Add it to a loaded model and wait for the |
1030 // saves to finish. | 1030 // saves to finish. |
1031 TemplateURL* t_url = CreatePreloadedTemplateURL(true, 999999); | 1031 TemplateURL* t_url = CreatePreloadedTemplateURL(true, 999999); |
1032 test_util()->ChangeModelToLoadState(); | 1032 test_util()->ChangeModelToLoadState(); |
1033 model()->Add(t_url); | 1033 model()->Add(t_url); |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 scoped_ptr<TemplateURL::AssociatedExtensionInfo> extension_info( | 1487 scoped_ptr<TemplateURL::AssociatedExtensionInfo> extension_info( |
1488 new TemplateURL::AssociatedExtensionInfo( | 1488 new TemplateURL::AssociatedExtensionInfo( |
1489 TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION, "ext1")); | 1489 TemplateURL::NORMAL_CONTROLLED_BY_EXTENSION, "ext1")); |
1490 extension_info->wants_to_be_default_engine = true; | 1490 extension_info->wants_to_be_default_engine = true; |
1491 model()->AddExtensionControlledTURL(ext_dse, extension_info.Pass()); | 1491 model()->AddExtensionControlledTURL(ext_dse, extension_info.Pass()); |
1492 EXPECT_EQ(ext_dse, model()->GetTemplateURLForKeyword(ASCIIToUTF16("ext1"))); | 1492 EXPECT_EQ(ext_dse, model()->GetTemplateURLForKeyword(ASCIIToUTF16("ext1"))); |
1493 EXPECT_TRUE(model()->is_default_search_managed()); | 1493 EXPECT_TRUE(model()->is_default_search_managed()); |
1494 actual_managed_default = model()->GetDefaultSearchProvider(); | 1494 actual_managed_default = model()->GetDefaultSearchProvider(); |
1495 ExpectSimilar(expected_managed_default.get(), actual_managed_default); | 1495 ExpectSimilar(expected_managed_default.get(), actual_managed_default); |
1496 } | 1496 } |
OLD | NEW |