| 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/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/scoped_ptr.h" | 6 #include "base/scoped_ptr.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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 | 377 |
| 378 // This tests for a regression where certain input in the omnibox caused us to | 378 // This tests for a regression where certain input in the omnibox caused us to |
| 379 // crash. As long as the test completes without crashing, we're fine. | 379 // crash. As long as the test completes without crashing, we're fine. |
| 380 TEST(AutocompleteTest, InputCrash) { | 380 TEST(AutocompleteTest, InputCrash) { |
| 381 AutocompleteInput input(L"\uff65@s", std::wstring(), true, false, true, | 381 AutocompleteInput input(L"\uff65@s", std::wstring(), true, false, true, |
| 382 false); | 382 false); |
| 383 } | 383 } |
| 384 | 384 |
| 385 // Test that we can properly compare matches' relevance when at least one is | 385 // Test comparing matches relevance. |
| 386 // negative. | |
| 387 TEST(AutocompleteMatch, MoreRelevant) { | 386 TEST(AutocompleteMatch, MoreRelevant) { |
| 388 struct RelevantCases { | 387 struct RelevantCases { |
| 389 int r1; | 388 int r1; |
| 390 int r2; | 389 int r2; |
| 391 bool expected_result; | 390 bool expected_result; |
| 392 } cases[] = { | 391 } cases[] = { |
| 393 { 10, 0, true }, | 392 { 10, 0, true }, |
| 394 { 10, -5, true }, | 393 { 10, -5, true }, |
| 395 { -5, 10, false }, | 394 { -5, 10, false }, |
| 396 { 0, 10, false }, | 395 { 0, 10, false }, |
| 397 { -10, -5, true }, | 396 { -10, -5, false }, |
| 398 { -5, -10, false }, | 397 { -5, -10, true }, |
| 399 }; | 398 }; |
| 400 | 399 |
| 401 AutocompleteMatch m1(NULL, 0, false, AutocompleteMatch::URL_WHAT_YOU_TYPED); | 400 AutocompleteMatch m1(NULL, 0, false, AutocompleteMatch::URL_WHAT_YOU_TYPED); |
| 402 AutocompleteMatch m2(NULL, 0, false, AutocompleteMatch::URL_WHAT_YOU_TYPED); | 401 AutocompleteMatch m2(NULL, 0, false, AutocompleteMatch::URL_WHAT_YOU_TYPED); |
| 403 | 402 |
| 404 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { | 403 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 405 m1.relevance = cases[i].r1; | 404 m1.relevance = cases[i].r1; |
| 406 m2.relevance = cases[i].r2; | 405 m2.relevance = cases[i].r2; |
| 407 EXPECT_EQ(cases[i].expected_result, | 406 EXPECT_EQ(cases[i].expected_result, |
| 408 AutocompleteMatch::MoreRelevant(m1, m2)); | 407 AutocompleteMatch::MoreRelevant(m1, m2)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " << | 448 EXPECT_EQ(input_cases[i].scheme.len, scheme.len) << "Input: " << |
| 450 input_cases[i].input; | 449 input_cases[i].input; |
| 451 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " << | 450 EXPECT_EQ(input_cases[i].host.begin, host.begin) << "Input: " << |
| 452 input_cases[i].input; | 451 input_cases[i].input; |
| 453 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " << | 452 EXPECT_EQ(input_cases[i].host.len, host.len) << "Input: " << |
| 454 input_cases[i].input; | 453 input_cases[i].input; |
| 455 } | 454 } |
| 456 } | 455 } |
| 457 | 456 |
| 458 } // namespace | 457 } // namespace |
| OLD | NEW |