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/bookmark_provider.h" | 5 #include "chrome/browser/autocomplete/bookmark_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 16 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
17 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 17 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
18 #include "chrome/browser/bookmarks/bookmark_model.h" | 18 #include "chrome/browser/bookmarks/bookmark_model.h" |
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 20 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" |
20 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
21 #include "components/bookmarks/core/browser/bookmark_title_match.h" | 22 #include "components/bookmarks/core/browser/bookmark_title_match.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 | 24 |
24 // The bookmark corpus against which we will simulate searches. | 25 // The bookmark corpus against which we will simulate searches. |
25 struct BookmarksTestInfo { | 26 struct BookmarksTestInfo { |
26 std::string title; | 27 std::string title; |
27 std::string url; | 28 std::string url; |
28 } bookmark_provider_test_data[] = { | 29 } bookmark_provider_test_data[] = { |
29 { "abc def", "http://www.catsanddogs.com/a" }, | 30 { "abc def", "http://www.catsanddogs.com/a" }, |
(...skipping 24 matching lines...) Expand all Loading... |
54 {"burning worms #1", "http://www.burned.com/" }, | 55 {"burning worms #1", "http://www.burned.com/" }, |
55 {"burning worms #2", "http://www.worms.com/" }, | 56 {"burning worms #2", "http://www.worms.com/" }, |
56 {"worming burns #10", "http://www.burned.com/" }, | 57 {"worming burns #10", "http://www.burned.com/" }, |
57 {"worming burns #20", "http://www.worms.com/" }, | 58 {"worming burns #20", "http://www.worms.com/" }, |
58 {"jive music", "http://www.worms.com/" }, | 59 {"jive music", "http://www.worms.com/" }, |
59 }; | 60 }; |
60 | 61 |
61 class BookmarkProviderTest : public testing::Test, | 62 class BookmarkProviderTest : public testing::Test, |
62 public AutocompleteProviderListener { | 63 public AutocompleteProviderListener { |
63 public: | 64 public: |
64 BookmarkProviderTest() : model_(new BookmarkModel(NULL)) {} | 65 BookmarkProviderTest() : model_(client_.CreateModel()) {} |
65 | 66 |
66 // AutocompleteProviderListener: Not called. | 67 // AutocompleteProviderListener: Not called. |
67 virtual void OnProviderUpdate(bool updated_matches) OVERRIDE {} | 68 virtual void OnProviderUpdate(bool updated_matches) OVERRIDE {} |
68 | 69 |
69 protected: | 70 protected: |
70 virtual void SetUp() OVERRIDE; | 71 virtual void SetUp() OVERRIDE; |
71 | 72 |
| 73 test::TestBookmarkClient client_; |
72 scoped_ptr<TestingProfile> profile_; | 74 scoped_ptr<TestingProfile> profile_; |
73 scoped_ptr<BookmarkModel> model_; | 75 scoped_ptr<BookmarkModel> model_; |
74 scoped_refptr<BookmarkProvider> provider_; | 76 scoped_refptr<BookmarkProvider> provider_; |
75 | 77 |
76 private: | 78 private: |
77 DISALLOW_COPY_AND_ASSIGN(BookmarkProviderTest); | 79 DISALLOW_COPY_AND_ASSIGN(BookmarkProviderTest); |
78 }; | 80 }; |
79 | 81 |
80 void BookmarkProviderTest::SetUp() { | 82 void BookmarkProviderTest::SetUp() { |
81 profile_.reset(new TestingProfile()); | 83 profile_.reset(new TestingProfile()); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 BookmarkTitleMatch bookmark_match; | 392 BookmarkTitleMatch bookmark_match; |
391 bookmark_match.node = &node; | 393 bookmark_match.node = &node; |
392 const AutocompleteMatch& ac_match = | 394 const AutocompleteMatch& ac_match = |
393 provider_->TitleMatchToACMatch(input, fixed_up_input, bookmark_match); | 395 provider_->TitleMatchToACMatch(input, fixed_up_input, bookmark_match); |
394 EXPECT_EQ(query_data[i].allowed_to_be_default_match, | 396 EXPECT_EQ(query_data[i].allowed_to_be_default_match, |
395 ac_match.allowed_to_be_default_match) << description; | 397 ac_match.allowed_to_be_default_match) << description; |
396 EXPECT_EQ(base::ASCIIToUTF16(query_data[i].inline_autocompletion), | 398 EXPECT_EQ(base::ASCIIToUTF16(query_data[i].inline_autocompletion), |
397 ac_match.inline_autocompletion) << description; | 399 ac_match.inline_autocompletion) << description; |
398 } | 400 } |
399 } | 401 } |
OLD | NEW |