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

Side by Side Diff: components/omnibox/browser/bookmark_provider_unittest.cc

Issue 2569333003: Rename BookmarkIndex to TitledUrlIndex and BookmarkMatch to TitledUrlMatch (Closed)
Patch Set: fix bookmark_bridge.cc Created 4 years 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
« no previous file with comments | « components/omnibox/browser/bookmark_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/omnibox/browser/bookmark_provider.h" 5 #include "components/omnibox/browser/bookmark_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "components/bookmarks/browser/bookmark_match.h"
22 #include "components/bookmarks/browser/bookmark_model.h" 21 #include "components/bookmarks/browser/bookmark_model.h"
22 #include "components/bookmarks/browser/titled_url_match.h"
23 #include "components/bookmarks/test/test_bookmark_client.h" 23 #include "components/bookmarks/test/test_bookmark_client.h"
24 #include "components/metrics/proto/omnibox_event.pb.h" 24 #include "components/metrics/proto/omnibox_event.pb.h"
25 #include "components/omnibox/browser/autocomplete_provider.h" 25 #include "components/omnibox/browser/autocomplete_provider.h"
26 #include "components/omnibox/browser/mock_autocomplete_provider_client.h" 26 #include "components/omnibox/browser/mock_autocomplete_provider_client.h"
27 #include "components/omnibox/browser/test_scheme_classifier.h" 27 #include "components/omnibox/browser/test_scheme_classifier.h"
28 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 30
31 using bookmarks::BookmarkMatch;
32 using bookmarks::BookmarkModel; 31 using bookmarks::BookmarkModel;
33 using bookmarks::BookmarkNode; 32 using bookmarks::BookmarkNode;
33 using bookmarks::TitledUrlMatch;
34 34
35 namespace { 35 namespace {
36 36
37 // The bookmark corpus against which we will simulate searches. 37 // The bookmark corpus against which we will simulate searches.
38 struct BookmarksTestInfo { 38 struct BookmarksTestInfo {
39 std::string title; 39 std::string title;
40 std::string url; 40 std::string url;
41 } bookmark_provider_test_data[] = { 41 } bookmark_provider_test_data[] = {
42 { "abc def", "http://www.catsanddogs.com/a" }, 42 { "abc def", "http://www.catsanddogs.com/a" },
43 { "abcde", "http://www.catsanddogs.com/b" }, 43 { "abcde", "http://www.catsanddogs.com/b" },
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 const std::string description = "for query=" + query_data[i].query + 413 const std::string description = "for query=" + query_data[i].query +
414 " and url=" + query_data[i].url; 414 " and url=" + query_data[i].url;
415 AutocompleteInput input(base::ASCIIToUTF16(query_data[i].query), 415 AutocompleteInput input(base::ASCIIToUTF16(query_data[i].query),
416 base::string16::npos, std::string(), GURL(), 416 base::string16::npos, std::string(), GURL(),
417 metrics::OmniboxEventProto::INVALID_SPEC, false, 417 metrics::OmniboxEventProto::INVALID_SPEC, false,
418 false, false, true, false, TestSchemeClassifier()); 418 false, false, true, false, TestSchemeClassifier());
419 const base::string16 fixed_up_input( 419 const base::string16 fixed_up_input(
420 provider_->FixupUserInput(input).second); 420 provider_->FixupUserInput(input).second);
421 BookmarkNode node(GURL(query_data[i].url)); 421 BookmarkNode node(GURL(query_data[i].url));
422 node.SetTitle(base::ASCIIToUTF16(query_data[i].url)); 422 node.SetTitle(base::ASCIIToUTF16(query_data[i].url));
423 BookmarkMatch bookmark_match; 423 TitledUrlMatch bookmark_match;
424 bookmark_match.node = &node; 424 bookmark_match.node = &node;
425 const AutocompleteMatch& ac_match = provider_->BookmarkMatchToACMatch( 425 const AutocompleteMatch& ac_match = provider_->TitledUrlMatchToACMatch(
426 input, fixed_up_input, bookmark_match); 426 input, fixed_up_input, bookmark_match);
427 EXPECT_EQ(query_data[i].allowed_to_be_default_match, 427 EXPECT_EQ(query_data[i].allowed_to_be_default_match,
428 ac_match.allowed_to_be_default_match) << description; 428 ac_match.allowed_to_be_default_match) << description;
429 EXPECT_EQ(base::ASCIIToUTF16(query_data[i].inline_autocompletion), 429 EXPECT_EQ(base::ASCIIToUTF16(query_data[i].inline_autocompletion),
430 ac_match.inline_autocompletion) << description; 430 ac_match.inline_autocompletion) << description;
431 } 431 }
432 } 432 }
433 433
434 TEST_F(BookmarkProviderTest, StripHttpAndAdjustOffsets) { 434 TEST_F(BookmarkProviderTest, StripHttpAndAdjustOffsets) {
435 // Simulate searches. 435 // Simulate searches.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 } 484 }
485 485
486 TEST_F(BookmarkProviderTest, DoesNotProvideMatchesOnFocus) { 486 TEST_F(BookmarkProviderTest, DoesNotProvideMatchesOnFocus) {
487 AutocompleteInput input(base::ASCIIToUTF16("foo"), base::string16::npos, 487 AutocompleteInput input(base::ASCIIToUTF16("foo"), base::string16::npos,
488 std::string(), GURL(), 488 std::string(), GURL(),
489 metrics::OmniboxEventProto::INVALID_SPEC, false, 489 metrics::OmniboxEventProto::INVALID_SPEC, false,
490 false, false, true, true, TestSchemeClassifier()); 490 false, false, true, true, TestSchemeClassifier());
491 provider_->Start(input, false); 491 provider_->Start(input, false);
492 EXPECT_TRUE(provider_->matches().empty()); 492 EXPECT_TRUE(provider_->matches().empty());
493 } 493 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/bookmark_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698