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/string_split.h" | 15 #include "base/strings/string_split.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 17 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
18 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
19 #include "components/bookmarks/browser/bookmark_match.h" | 19 #include "components/bookmarks/browser/bookmark_match.h" |
20 #include "components/bookmarks/browser/bookmark_model.h" | 20 #include "components/bookmarks/browser/bookmark_model.h" |
21 #include "components/bookmarks/test/test_bookmark_client.h" | 21 #include "components/bookmarks/test/test_bookmark_client.h" |
22 #include "components/metrics/proto/omnibox_event.pb.h" | 22 #include "components/metrics/proto/omnibox_event.pb.h" |
23 #include "components/omnibox/autocomplete_provider.h" | 23 #include "components/omnibox/autocomplete_provider.h" |
| 24 #include "content/public/test/test_browser_thread_bundle.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 | 26 |
26 using bookmarks::BookmarkMatch; | 27 using bookmarks::BookmarkMatch; |
27 using bookmarks::BookmarkModel; | 28 using bookmarks::BookmarkModel; |
28 using bookmarks::BookmarkNode; | 29 using bookmarks::BookmarkNode; |
29 | 30 |
30 // The bookmark corpus against which we will simulate searches. | 31 // The bookmark corpus against which we will simulate searches. |
31 struct BookmarksTestInfo { | 32 struct BookmarksTestInfo { |
32 std::string title; | 33 std::string title; |
33 std::string url; | 34 std::string url; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 { "", "http://emptytitle.com/" }, | 68 { "", "http://emptytitle.com/" }, |
68 }; | 69 }; |
69 | 70 |
70 class BookmarkProviderTest : public testing::Test { | 71 class BookmarkProviderTest : public testing::Test { |
71 public: | 72 public: |
72 BookmarkProviderTest(); | 73 BookmarkProviderTest(); |
73 | 74 |
74 protected: | 75 protected: |
75 void SetUp() override; | 76 void SetUp() override; |
76 | 77 |
| 78 content::TestBrowserThreadBundle thread_bundle_; |
77 bookmarks::TestBookmarkClient client_; | 79 bookmarks::TestBookmarkClient client_; |
78 scoped_ptr<TestingProfile> profile_; | 80 scoped_ptr<TestingProfile> profile_; |
79 scoped_ptr<BookmarkModel> model_; | 81 scoped_ptr<BookmarkModel> model_; |
80 scoped_refptr<BookmarkProvider> provider_; | 82 scoped_refptr<BookmarkProvider> provider_; |
81 | 83 |
82 private: | 84 private: |
83 DISALLOW_COPY_AND_ASSIGN(BookmarkProviderTest); | 85 DISALLOW_COPY_AND_ASSIGN(BookmarkProviderTest); |
84 }; | 86 }; |
85 | 87 |
86 BookmarkProviderTest::BookmarkProviderTest() { | 88 BookmarkProviderTest::BookmarkProviderTest() { |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 | 479 |
478 TEST_F(BookmarkProviderTest, DoesNotProvideMatchesOnFocus) { | 480 TEST_F(BookmarkProviderTest, DoesNotProvideMatchesOnFocus) { |
479 AutocompleteInput input(base::ASCIIToUTF16("foo"), | 481 AutocompleteInput input(base::ASCIIToUTF16("foo"), |
480 base::string16::npos, std::string(), GURL(), | 482 base::string16::npos, std::string(), GURL(), |
481 metrics::OmniboxEventProto::INVALID_SPEC, false, | 483 metrics::OmniboxEventProto::INVALID_SPEC, false, |
482 false, false, true, | 484 false, false, true, |
483 ChromeAutocompleteSchemeClassifier(profile_.get())); | 485 ChromeAutocompleteSchemeClassifier(profile_.get())); |
484 provider_->Start(input, false, true); | 486 provider_->Start(input, false, true); |
485 EXPECT_TRUE(provider_->matches().empty()); | 487 EXPECT_TRUE(provider_->matches().empty()); |
486 } | 488 } |
OLD | NEW |