| OLD | NEW |
| 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete.h" | 10 #include "chrome/browser/autocomplete/autocomplete.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 void TestProvider::Run() { | 80 void TestProvider::Run() { |
| 81 DCHECK_GT(num_results_per_provider, 0U); | 81 DCHECK_GT(num_results_per_provider, 0U); |
| 82 AddResults(1, num_results_per_provider); | 82 AddResults(1, num_results_per_provider); |
| 83 done_ = true; | 83 done_ = true; |
| 84 DCHECK(listener_); | 84 DCHECK(listener_); |
| 85 listener_->OnProviderUpdate(true); | 85 listener_->OnProviderUpdate(true); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void TestProvider::AddResults(int start_at, int num) { | 88 void TestProvider::AddResults(int start_at, int num) { |
| 89 for (int i = start_at; i < num; i++) { | 89 for (int i = start_at; i < num; i++) { |
| 90 AutocompleteMatch match(this, relevance_ - i, false, | 90 AutocompleteMatch match(this, relevance_ - i, 0.0f, false, |
| 91 AutocompleteMatch::URL_WHAT_YOU_TYPED); | 91 AutocompleteMatch::URL_WHAT_YOU_TYPED); |
| 92 | 92 |
| 93 match.fill_into_edit = prefix_ + UTF8ToUTF16(base::IntToString(i)); | 93 match.fill_into_edit = prefix_ + UTF8ToUTF16(base::IntToString(i)); |
| 94 match.destination_url = GURL(UTF16ToUTF8(match.fill_into_edit)); | 94 match.destination_url = GURL(UTF16ToUTF8(match.fill_into_edit)); |
| 95 | 95 |
| 96 match.contents = match.fill_into_edit; | 96 match.contents = match.fill_into_edit; |
| 97 match.contents_class.push_back( | 97 match.contents_class.push_back( |
| 98 ACMatchClassification(0, ACMatchClassification::NONE)); | 98 ACMatchClassification(0, ACMatchClassification::NONE)); |
| 99 match.description = match.fill_into_edit; | 99 match.description = match.fill_into_edit; |
| 100 match.description_class.push_back( | 100 match.description_class.push_back( |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 bool expected_result; | 408 bool expected_result; |
| 409 } cases[] = { | 409 } cases[] = { |
| 410 { 10, 0, true }, | 410 { 10, 0, true }, |
| 411 { 10, -5, true }, | 411 { 10, -5, true }, |
| 412 { -5, 10, false }, | 412 { -5, 10, false }, |
| 413 { 0, 10, false }, | 413 { 0, 10, false }, |
| 414 { -10, -5, false }, | 414 { -10, -5, false }, |
| 415 { -5, -10, true }, | 415 { -5, -10, true }, |
| 416 }; | 416 }; |
| 417 | 417 |
| 418 AutocompleteMatch m1(NULL, 0, false, AutocompleteMatch::URL_WHAT_YOU_TYPED); | 418 AutocompleteMatch m1(NULL, 0, 0.0f, false, |
| 419 AutocompleteMatch m2(NULL, 0, false, AutocompleteMatch::URL_WHAT_YOU_TYPED); | 419 AutocompleteMatch::URL_WHAT_YOU_TYPED); |
| 420 AutocompleteMatch m2(NULL, 0, 0.0f, false, |
| 421 AutocompleteMatch::URL_WHAT_YOU_TYPED); |
| 420 | 422 |
| 421 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { | 423 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 422 m1.relevance = cases[i].r1; | 424 m1.relevance = cases[i].r1; |
| 423 m2.relevance = cases[i].r2; | 425 m2.relevance = cases[i].r2; |
| 424 EXPECT_EQ(cases[i].expected_result, | 426 EXPECT_EQ(cases[i].expected_result, |
| 425 AutocompleteMatch::MoreRelevant(m1, m2)); | 427 AutocompleteMatch::MoreRelevant(m1, m2)); |
| 426 } | 428 } |
| 427 } | 429 } |
| 428 | 430 |
| 429 TEST(AutocompleteInput, ParseForEmphasizeComponent) { | 431 TEST(AutocompleteInput, ParseForEmphasizeComponent) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " << | 475 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " << |
| 474 input_cases[i].input; | 476 input_cases[i].input; |
| 475 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " << | 477 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " << |
| 476 input_cases[i].input; | 478 input_cases[i].input; |
| 477 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " << | 479 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " << |
| 478 input_cases[i].input; | 480 input_cases[i].input; |
| 479 } | 481 } |
| 480 } | 482 } |
| 481 | 483 |
| 482 } // namespace | 484 } // namespace |
| OLD | NEW |