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

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

Issue 959343004: Move InMemoryURLIndex outside of history namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@in-memory-url-index
Patch Set: Created 5 years, 9 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 "chrome/browser/autocomplete/history_quick_provider.h" 5 #include "chrome/browser/autocomplete/history_quick_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 EXPECT_LT(citer->offset, max_offset); 544 EXPECT_LT(citer->offset, max_offset);
545 ACMatchClassifications description(ac_matches_[0].description_class); 545 ACMatchClassifications description(ac_matches_[0].description_class);
546 std::string page_title("Dogs & Cats & Mice & Other Animals"); 546 std::string page_title("Dogs & Cats & Mice & Other Animals");
547 for (ACMatchClassifications::const_iterator diter = description.begin(); 547 for (ACMatchClassifications::const_iterator diter = description.begin();
548 diter != description.end(); ++diter) 548 diter != description.end(); ++diter)
549 EXPECT_LT(diter->offset, page_title.length()); 549 EXPECT_LT(diter->offset, page_title.length());
550 } 550 }
551 551
552 TEST_F(HistoryQuickProviderTest, Spans) { 552 TEST_F(HistoryQuickProviderTest, Spans) {
553 // Test SpansFromTermMatch 553 // Test SpansFromTermMatch
554 history::TermMatches matches_a; 554 TermMatches matches_a;
555 // Simulates matches: '.xx.xxx..xx...xxxxx..' which will test no match at 555 // Simulates matches: '.xx.xxx..xx...xxxxx..' which will test no match at
556 // either beginning or end as well as adjacent matches. 556 // either beginning or end as well as adjacent matches.
557 matches_a.push_back(history::TermMatch(1, 1, 2)); 557 matches_a.push_back(TermMatch(1, 1, 2));
558 matches_a.push_back(history::TermMatch(2, 4, 3)); 558 matches_a.push_back(TermMatch(2, 4, 3));
559 matches_a.push_back(history::TermMatch(3, 9, 1)); 559 matches_a.push_back(TermMatch(3, 9, 1));
560 matches_a.push_back(history::TermMatch(3, 10, 1)); 560 matches_a.push_back(TermMatch(3, 10, 1));
561 matches_a.push_back(history::TermMatch(4, 14, 5)); 561 matches_a.push_back(TermMatch(4, 14, 5));
562 ACMatchClassifications spans_a = 562 ACMatchClassifications spans_a =
563 HistoryQuickProvider::SpansFromTermMatch(matches_a, 20, false); 563 HistoryQuickProvider::SpansFromTermMatch(matches_a, 20, false);
564 // ACMatch spans should be: 'NM-NM---N-M-N--M----N-' 564 // ACMatch spans should be: 'NM-NM---N-M-N--M----N-'
565 ASSERT_EQ(9U, spans_a.size()); 565 ASSERT_EQ(9U, spans_a.size());
566 EXPECT_EQ(0U, spans_a[0].offset); 566 EXPECT_EQ(0U, spans_a[0].offset);
567 EXPECT_EQ(ACMatchClassification::NONE, spans_a[0].style); 567 EXPECT_EQ(ACMatchClassification::NONE, spans_a[0].style);
568 EXPECT_EQ(1U, spans_a[1].offset); 568 EXPECT_EQ(1U, spans_a[1].offset);
569 EXPECT_EQ(ACMatchClassification::MATCH, spans_a[1].style); 569 EXPECT_EQ(ACMatchClassification::MATCH, spans_a[1].style);
570 EXPECT_EQ(3U, spans_a[2].offset); 570 EXPECT_EQ(3U, spans_a[2].offset);
571 EXPECT_EQ(ACMatchClassification::NONE, spans_a[2].style); 571 EXPECT_EQ(ACMatchClassification::NONE, spans_a[2].style);
572 EXPECT_EQ(4U, spans_a[3].offset); 572 EXPECT_EQ(4U, spans_a[3].offset);
573 EXPECT_EQ(ACMatchClassification::MATCH, spans_a[3].style); 573 EXPECT_EQ(ACMatchClassification::MATCH, spans_a[3].style);
574 EXPECT_EQ(7U, spans_a[4].offset); 574 EXPECT_EQ(7U, spans_a[4].offset);
575 EXPECT_EQ(ACMatchClassification::NONE, spans_a[4].style); 575 EXPECT_EQ(ACMatchClassification::NONE, spans_a[4].style);
576 EXPECT_EQ(9U, spans_a[5].offset); 576 EXPECT_EQ(9U, spans_a[5].offset);
577 EXPECT_EQ(ACMatchClassification::MATCH, spans_a[5].style); 577 EXPECT_EQ(ACMatchClassification::MATCH, spans_a[5].style);
578 EXPECT_EQ(11U, spans_a[6].offset); 578 EXPECT_EQ(11U, spans_a[6].offset);
579 EXPECT_EQ(ACMatchClassification::NONE, spans_a[6].style); 579 EXPECT_EQ(ACMatchClassification::NONE, spans_a[6].style);
580 EXPECT_EQ(14U, spans_a[7].offset); 580 EXPECT_EQ(14U, spans_a[7].offset);
581 EXPECT_EQ(ACMatchClassification::MATCH, spans_a[7].style); 581 EXPECT_EQ(ACMatchClassification::MATCH, spans_a[7].style);
582 EXPECT_EQ(19U, spans_a[8].offset); 582 EXPECT_EQ(19U, spans_a[8].offset);
583 EXPECT_EQ(ACMatchClassification::NONE, spans_a[8].style); 583 EXPECT_EQ(ACMatchClassification::NONE, spans_a[8].style);
584 // Simulates matches: 'xx.xx' which will test matches at both beginning and 584 // Simulates matches: 'xx.xx' which will test matches at both beginning and
585 // end. 585 // end.
586 history::TermMatches matches_b; 586 TermMatches matches_b;
587 matches_b.push_back(history::TermMatch(1, 0, 2)); 587 matches_b.push_back(TermMatch(1, 0, 2));
588 matches_b.push_back(history::TermMatch(2, 3, 2)); 588 matches_b.push_back(TermMatch(2, 3, 2));
589 ACMatchClassifications spans_b = 589 ACMatchClassifications spans_b =
590 HistoryQuickProvider::SpansFromTermMatch(matches_b, 5, true); 590 HistoryQuickProvider::SpansFromTermMatch(matches_b, 5, true);
591 // ACMatch spans should be: 'M-NM-' 591 // ACMatch spans should be: 'M-NM-'
592 ASSERT_EQ(3U, spans_b.size()); 592 ASSERT_EQ(3U, spans_b.size());
593 EXPECT_EQ(0U, spans_b[0].offset); 593 EXPECT_EQ(0U, spans_b[0].offset);
594 EXPECT_EQ(ACMatchClassification::MATCH | ACMatchClassification::URL, 594 EXPECT_EQ(ACMatchClassification::MATCH | ACMatchClassification::URL,
595 spans_b[0].style); 595 spans_b[0].style);
596 EXPECT_EQ(2U, spans_b[1].offset); 596 EXPECT_EQ(2U, spans_b[1].offset);
597 EXPECT_EQ(ACMatchClassification::URL, spans_b[1].style); 597 EXPECT_EQ(ACMatchClassification::URL, spans_b[1].style);
598 EXPECT_EQ(3U, spans_b[2].offset); 598 EXPECT_EQ(3U, spans_b[2].offset);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 824
825 TEST_F(HQPOrderingTest, TEAMatch) { 825 TEST_F(HQPOrderingTest, TEAMatch) {
826 std::vector<std::string> expected_urls; 826 std::vector<std::string> expected_urls;
827 expected_urls.push_back("http://www.teamliquid.net/"); 827 expected_urls.push_back("http://www.teamliquid.net/");
828 expected_urls.push_back("http://www.teamliquid.net/tlpd"); 828 expected_urls.push_back("http://www.teamliquid.net/tlpd");
829 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); 829 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players");
830 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true, 830 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true,
831 ASCIIToUTF16("www.teamliquid.net"), 831 ASCIIToUTF16("www.teamliquid.net"),
832 ASCIIToUTF16("mliquid.net")); 832 ASCIIToUTF16("mliquid.net"));
833 } 833 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698