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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_popup_model_unittest.cc

Issue 8253002: Move PageTransition into content namespace. While I'm touching all these files, I've also updated... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/autocomplete/autocomplete_popup_model.h" 5 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/autocomplete/autocomplete_match.h" 8 #include "chrome/browser/autocomplete/autocomplete_match.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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 template_url_service->GetTemplateURLForKeyword(keyword); 79 template_url_service->GetTemplateURLForKeyword(keyword);
80 match.template_url = 80 match.template_url =
81 TemplateURL::SupportsReplacement(template_url) ? template_url : NULL; 81 TemplateURL::SupportsReplacement(template_url) ? template_url : NULL;
82 } 82 }
83 if (match.template_url) 83 if (match.template_url)
84 match.fill_into_edit = match.template_url->keyword() + char16(' '); 84 match.fill_into_edit = match.template_url->keyword() + char16(' ');
85 else 85 else
86 match.template_url = template_url_service->GetDefaultSearchProvider(); 86 match.template_url = template_url_service->GetDefaultSearchProvider();
87 match.fill_into_edit.append(query_string); 87 match.fill_into_edit.append(query_string);
88 match.transition = keyword.empty() ? 88 match.transition = keyword.empty() ?
89 PageTransition::GENERATED : PageTransition::KEYWORD; 89 content::PAGE_TRANSITION_GENERATED : content::PAGE_TRANSITION_KEYWORD;
90 return match; 90 return match;
91 } 91 }
92 92
93 void AutoCompletePopupModelTest::RunTest(const char* input, 93 void AutoCompletePopupModelTest::RunTest(const char* input,
94 AutocompleteMatch::Type type, 94 AutocompleteMatch::Type type,
95 const char* keyword) { 95 const char* keyword) {
96 string16 keyword16(ASCIIToUTF16(keyword)); 96 string16 keyword16(ASCIIToUTF16(keyword));
97 string16 detected_keyword; 97 string16 detected_keyword;
98 EXPECT_FALSE(model_->GetKeywordForMatch( 98 EXPECT_FALSE(model_->GetKeywordForMatch(
99 CreateMatch(keyword16, ASCIIToUTF16(input), type), &detected_keyword)); 99 CreateMatch(keyword16, ASCIIToUTF16(input), type), &detected_keyword));
100 EXPECT_EQ(keyword16, detected_keyword); 100 EXPECT_EQ(keyword16, detected_keyword);
101 } 101 }
102 102
103 TEST_F(AutoCompletePopupModelTest, GetKeywordForMatch) { 103 TEST_F(AutoCompletePopupModelTest, GetKeywordForMatch) {
104 string16 keyword; 104 string16 keyword;
105 105
106 // Possible matches when the input is "tfoo" 106 // Possible matches when the input is "tfoo"
107 RunTest("tfoo", AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, ""); 107 RunTest("tfoo", AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, "");
108 RunTest("tfoo", AutocompleteMatch::SEARCH_HISTORY, ""); 108 RunTest("tfoo", AutocompleteMatch::SEARCH_HISTORY, "");
109 RunTest("tfoo", AutocompleteMatch::SEARCH_SUGGEST, ""); 109 RunTest("tfoo", AutocompleteMatch::SEARCH_SUGGEST, "");
110 110
111 // Possible matches when the input is "t foo" 111 // Possible matches when the input is "t foo"
112 RunTest("foo", AutocompleteMatch::SEARCH_HISTORY, "t"); 112 RunTest("foo", AutocompleteMatch::SEARCH_HISTORY, "t");
113 RunTest("foo", AutocompleteMatch::SEARCH_OTHER_ENGINE, "t"); 113 RunTest("foo", AutocompleteMatch::SEARCH_OTHER_ENGINE, "t");
114 114
115 // Possible matches when the input is "k foo" 115 // Possible matches when the input is "k foo"
116 RunTest("foo", AutocompleteMatch::SEARCH_HISTORY, "k"); 116 RunTest("foo", AutocompleteMatch::SEARCH_HISTORY, "k");
117 RunTest("foo", AutocompleteMatch::SEARCH_OTHER_ENGINE, "k"); 117 RunTest("foo", AutocompleteMatch::SEARCH_OTHER_ENGINE, "k");
118 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698