| 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 "chrome/browser/autocomplete/shortcuts_provider.h" | 5 #include "chrome/browser/autocomplete/shortcuts_provider.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <functional> | 10 #include <functional> |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 EXPECT_EQ(ACMatchClassification::URL | ACMatchClassification::MATCH, | 499 EXPECT_EQ(ACMatchClassification::URL | ACMatchClassification::MATCH, |
| 500 spans_i[3].style); | 500 spans_i[3].style); |
| 501 EXPECT_EQ(17U, spans_i[4].offset); | 501 EXPECT_EQ(17U, spans_i[4].offset); |
| 502 EXPECT_EQ(ACMatchClassification::URL, spans_i[4].style); | 502 EXPECT_EQ(ACMatchClassification::URL, spans_i[4].style); |
| 503 | 503 |
| 504 // Some web sites do not have a description, so second and third parameters in | 504 // Some web sites do not have a description, so second and third parameters in |
| 505 // ClassifyAllMatchesInString could be empty. | 505 // ClassifyAllMatchesInString could be empty. |
| 506 // Extra parens in the next line hack around C++03's "most vexing parse". | 506 // Extra parens in the next line hack around C++03's "most vexing parse". |
| 507 class ClassifyTest classify_test5((string16()), ACMatchClassifications()); | 507 class ClassifyTest classify_test5((string16()), ACMatchClassifications()); |
| 508 ACMatchClassifications spans_j = classify_test5.RunTest(ASCIIToUTF16("man")); | 508 ACMatchClassifications spans_j = classify_test5.RunTest(ASCIIToUTF16("man")); |
| 509 ASSERT_EQ(0U, spans_j.size()); | 509 ASSERT_EQ(1U, spans_j.size()); |
| 510 EXPECT_EQ(0U, spans_j.front().offset); |
| 511 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::NONE, |
| 512 spans_j.front().style); |
| 510 | 513 |
| 511 // Matches which end at beginning of classification merge properly. | 514 // Matches which end at beginning of classification merge properly. |
| 512 matches.clear(); | 515 matches.clear(); |
| 513 matches.push_back(ACMatchClassification(0, ACMatchClassification::DIM)); | 516 matches.push_back(ACMatchClassification(0, ACMatchClassification::DIM)); |
| 514 matches.push_back(ACMatchClassification(9, ACMatchClassification::NONE)); | 517 matches.push_back(ACMatchClassification(9, ACMatchClassification::NONE)); |
| 515 ClassifyTest classify_test6(ASCIIToUTF16("html password example"), matches); | 518 ClassifyTest classify_test6(ASCIIToUTF16("html password example"), matches); |
| 516 | 519 |
| 517 // Extra space in the next string avoids having the string be a prefix of the | 520 // Extra space in the next string avoids having the string be a prefix of the |
| 518 // text above, which would allow for two different valid classification sets, | 521 // text above, which would allow for two different valid classification sets, |
| 519 // one of which uses two spans (the first of which would mark all of "html | 522 // one of which uses two spans (the first of which would mark all of "html |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 | 668 |
| 666 match.destination_url = GURL(shortcuts_to_test_delete[2].url); | 669 match.destination_url = GURL(shortcuts_to_test_delete[2].url); |
| 667 match.contents = ASCIIToUTF16(shortcuts_to_test_delete[2].contents); | 670 match.contents = ASCIIToUTF16(shortcuts_to_test_delete[2].contents); |
| 668 match.description = ASCIIToUTF16(shortcuts_to_test_delete[2].description); | 671 match.description = ASCIIToUTF16(shortcuts_to_test_delete[2].description); |
| 669 | 672 |
| 670 provider_->DeleteMatch(match); | 673 provider_->DeleteMatch(match); |
| 671 EXPECT_EQ(original_shortcuts_count, backend_->shortcuts_map().size()); | 674 EXPECT_EQ(original_shortcuts_count, backend_->shortcuts_map().size()); |
| 672 EXPECT_TRUE(backend_->shortcuts_map().end() == | 675 EXPECT_TRUE(backend_->shortcuts_map().end() == |
| 673 backend_->shortcuts_map().find(ASCIIToUTF16("delete"))); | 676 backend_->shortcuts_map().find(ASCIIToUTF16("delete"))); |
| 674 } | 677 } |
| OLD | NEW |