OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/shortcuts_provider_test_util.h" | 5 #include "components/omnibox/browser/shortcuts_provider_test_util.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "components/omnibox/browser/autocomplete_match.h" | 9 #include "components/omnibox/browser/autocomplete_match.h" |
10 #include "components/omnibox/browser/shortcuts_backend.h" | 10 #include "components/omnibox/browser/shortcuts_backend.h" |
11 #include "components/omnibox/browser/shortcuts_provider.h" | 11 #include "components/omnibox/browser/shortcuts_provider.h" |
12 #include "components/omnibox/browser/test_scheme_classifier.h" | 12 #include "components/omnibox/browser/test_scheme_classifier.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 TestShortcutData::TestShortcutData(std::string guid, | 15 TestShortcutData::TestShortcutData(std::string guid, |
16 std::string text, | 16 std::string text, |
17 std::string fill_into_edit, | 17 std::string fill_into_edit, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 EXPECT_EQ(expected_size, backend->shortcuts_map().size()); | 63 EXPECT_EQ(expected_size, backend->shortcuts_map().size()); |
64 } | 64 } |
65 | 65 |
66 void RunShortcutsProviderTest( | 66 void RunShortcutsProviderTest( |
67 scoped_refptr<ShortcutsProvider> provider, | 67 scoped_refptr<ShortcutsProvider> provider, |
68 const base::string16 text, | 68 const base::string16 text, |
69 bool prevent_inline_autocomplete, | 69 bool prevent_inline_autocomplete, |
70 const std::vector<ExpectedURLAndAllowedToBeDefault>& expected_urls, | 70 const std::vector<ExpectedURLAndAllowedToBeDefault>& expected_urls, |
71 std::string expected_top_result, | 71 std::string expected_top_result, |
72 base::string16 top_result_inline_autocompletion) { | 72 base::string16 top_result_inline_autocompletion) { |
73 base::MessageLoop::current()->RunUntilIdle(); | 73 base::RunLoop().RunUntilIdle(); |
74 AutocompleteInput input(text, base::string16::npos, std::string(), GURL(), | 74 AutocompleteInput input(text, base::string16::npos, std::string(), GURL(), |
75 metrics::OmniboxEventProto::INVALID_SPEC, | 75 metrics::OmniboxEventProto::INVALID_SPEC, |
76 prevent_inline_autocomplete, false, true, true, false, | 76 prevent_inline_autocomplete, false, true, true, false, |
77 TestSchemeClassifier()); | 77 TestSchemeClassifier()); |
78 provider->Start(input, false); | 78 provider->Start(input, false); |
79 EXPECT_TRUE(provider->done()); | 79 EXPECT_TRUE(provider->done()); |
80 | 80 |
81 ACMatches ac_matches = provider->matches(); | 81 ACMatches ac_matches = provider->matches(); |
82 | 82 |
83 // We should have gotten back at most AutocompleteProvider::kMaxMatches. | 83 // We should have gotten back at most AutocompleteProvider::kMaxMatches. |
(...skipping 15 matching lines...) Expand all Loading... |
99 | 99 |
100 // See if we got the expected top scorer. | 100 // See if we got the expected top scorer. |
101 if (!ac_matches.empty()) { | 101 if (!ac_matches.empty()) { |
102 std::partial_sort(ac_matches.begin(), ac_matches.begin() + 1, | 102 std::partial_sort(ac_matches.begin(), ac_matches.begin() + 1, |
103 ac_matches.end(), AutocompleteMatch::MoreRelevant); | 103 ac_matches.end(), AutocompleteMatch::MoreRelevant); |
104 EXPECT_EQ(expected_top_result, ac_matches[0].destination_url.spec()); | 104 EXPECT_EQ(expected_top_result, ac_matches[0].destination_url.spec()); |
105 EXPECT_EQ(top_result_inline_autocompletion, | 105 EXPECT_EQ(top_result_inline_autocompletion, |
106 ac_matches[0].inline_autocompletion); | 106 ac_matches[0].inline_autocompletion); |
107 } | 107 } |
108 } | 108 } |
OLD | NEW |