Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(948)

Side by Side Diff: components/search_engines/template_url_service_unittest.cc

Issue 658993002: Convert ARRAYSIZE_UNSAFE -> arraysize in components/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 { "http://x/foo?q=b#query=xx", ASCIIToUTF16("xx") }, 882 { "http://x/foo?q=b#query=xx", ASCIIToUTF16("xx") },
883 { "http://x/foo?q=b#q=xx", ASCIIToUTF16("b") }, 883 { "http://x/foo?q=b#q=xx", ASCIIToUTF16("b") },
884 { "http://x/foo?query=b#q=xx", base::string16() }, 884 { "http://x/foo?query=b#q=xx", base::string16() },
885 }; 885 };
886 886
887 test_util()->ChangeModelToLoadState(); 887 test_util()->ChangeModelToLoadState();
888 AddKeywordWithDate("name", "x", "http://x/foo?q={searchTerms}", 888 AddKeywordWithDate("name", "x", "http://x/foo?q={searchTerms}",
889 "http://sugg1", "http://x/foo#query={searchTerms}", 889 "http://sugg1", "http://x/foo#query={searchTerms}",
890 "http://icon1", false, "UTF-8;UTF-16", Time(), Time()); 890 "http://icon1", false, "UTF-8;UTF-16", Time(), Time());
891 891
892 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { 892 for (size_t i = 0; i < arraysize(data); ++i) {
893 TemplateURLService::URLVisitedDetails details = { 893 TemplateURLService::URLVisitedDetails details = {
894 GURL(data[i].url), false 894 GURL(data[i].url), false
895 }; 895 };
896 model()->UpdateKeywordSearchTermsForURL(details); 896 model()->UpdateKeywordSearchTermsForURL(details);
897 EXPECT_EQ(data[i].term, test_util()->GetAndClearSearchTerm()); 897 EXPECT_EQ(data[i].term, test_util()->GetAndClearSearchTerm());
898 } 898 }
899 } 899 }
900 900
901 TEST_F(TemplateURLServiceTest, DontUpdateKeywordSearchForNonReplaceable) { 901 TEST_F(TemplateURLServiceTest, DontUpdateKeywordSearchForNonReplaceable) {
902 struct TestData { 902 struct TestData {
903 const std::string url; 903 const std::string url;
904 } data[] = { 904 } data[] = {
905 { "http://foo/" }, 905 { "http://foo/" },
906 { "http://x/bar?q=xx" }, 906 { "http://x/bar?q=xx" },
907 { "http://x/foo?y=xx" }, 907 { "http://x/foo?y=xx" },
908 }; 908 };
909 909
910 test_util()->ChangeModelToLoadState(); 910 test_util()->ChangeModelToLoadState();
911 AddKeywordWithDate("name", "x", "http://x/foo", "http://sugg1", std::string(), 911 AddKeywordWithDate("name", "x", "http://x/foo", "http://sugg1", std::string(),
912 "http://icon1", false, "UTF-8;UTF-16", Time(), Time()); 912 "http://icon1", false, "UTF-8;UTF-16", Time(), Time());
913 913
914 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { 914 for (size_t i = 0; i < arraysize(data); ++i) {
915 TemplateURLService::URLVisitedDetails details = { 915 TemplateURLService::URLVisitedDetails details = {
916 GURL(data[i].url), false 916 GURL(data[i].url), false
917 }; 917 };
918 model()->UpdateKeywordSearchTermsForURL(details); 918 model()->UpdateKeywordSearchTermsForURL(details);
919 ASSERT_EQ(base::string16(), test_util()->GetAndClearSearchTerm()); 919 ASSERT_EQ(base::string16(), test_util()->GetAndClearSearchTerm());
920 } 920 }
921 } 921 }
922 922
923 TEST_F(TemplateURLServiceWithoutFallbackTest, ChangeGoogleBaseValue) { 923 TEST_F(TemplateURLServiceWithoutFallbackTest, ChangeGoogleBaseValue) {
924 // NOTE: Do not load the prepopulate data, which also has a {google:baseURL} 924 // NOTE: Do not load the prepopulate data, which also has a {google:baseURL}
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « components/search_engines/template_url_service_sync_unittest.cc ('k') | components/search_engines/template_url_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698