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/shortcuts_provider.h" | 5 #include "chrome/browser/autocomplete/shortcuts_provider.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <functional> | 10 #include <functional> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 23 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
24 #include "chrome/browser/autocomplete/autocomplete_result.h" | 24 #include "chrome/browser/autocomplete/autocomplete_result.h" |
25 #include "chrome/browser/autocomplete/shortcuts_backend.h" | 25 #include "chrome/browser/autocomplete/shortcuts_backend.h" |
26 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" | 26 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" |
27 #include "chrome/browser/chrome_notification_types.h" | 27 #include "chrome/browser/chrome_notification_types.h" |
28 #include "chrome/browser/history/history_service.h" | 28 #include "chrome/browser/history/history_service.h" |
29 #include "chrome/browser/history/in_memory_url_index.h" | 29 #include "chrome/browser/history/in_memory_url_index.h" |
30 #include "chrome/browser/history/url_database.h" | 30 #include "chrome/browser/history/url_database.h" |
31 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
32 #include "chrome/test/base/testing_profile.h" | 32 #include "chrome/test/base/testing_profile.h" |
| 33 #include "components/metrics/proto/omnibox_event.pb.h" |
33 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
34 #include "content/public/test/test_browser_thread.h" | 35 #include "content/public/test/test_browser_thread.h" |
35 #include "extensions/common/extension.h" | 36 #include "extensions/common/extension.h" |
36 #include "extensions/common/extension_builder.h" | 37 #include "extensions/common/extension_builder.h" |
37 #include "extensions/common/value_builder.h" | 38 #include "extensions/common/value_builder.h" |
38 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
39 | 40 |
40 using base::ASCIIToUTF16; | 41 using base::ASCIIToUTF16; |
41 | 42 |
42 // TestShortcutInfo ----------------------------------------------------------- | 43 // TestShortcutInfo ----------------------------------------------------------- |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 } | 354 } |
354 | 355 |
355 void ShortcutsProviderTest::RunTest( | 356 void ShortcutsProviderTest::RunTest( |
356 const base::string16 text, | 357 const base::string16 text, |
357 bool prevent_inline_autocomplete, | 358 bool prevent_inline_autocomplete, |
358 const ExpectedURLs& expected_urls, | 359 const ExpectedURLs& expected_urls, |
359 std::string expected_top_result, | 360 std::string expected_top_result, |
360 base::string16 top_result_inline_autocompletion) { | 361 base::string16 top_result_inline_autocompletion) { |
361 base::MessageLoop::current()->RunUntilIdle(); | 362 base::MessageLoop::current()->RunUntilIdle(); |
362 AutocompleteInput input(text, base::string16::npos, base::string16(), GURL(), | 363 AutocompleteInput input(text, base::string16::npos, base::string16(), GURL(), |
363 AutocompleteInput::INVALID_SPEC, | 364 metrics::OmniboxEventProto::INVALID_SPEC, |
364 prevent_inline_autocomplete, false, true, true); | 365 prevent_inline_autocomplete, false, true, true); |
365 provider_->Start(input, false); | 366 provider_->Start(input, false); |
366 EXPECT_TRUE(provider_->done()); | 367 EXPECT_TRUE(provider_->done()); |
367 | 368 |
368 ac_matches_ = provider_->matches(); | 369 ac_matches_ = provider_->matches(); |
369 | 370 |
370 // We should have gotten back at most AutocompleteProvider::kMaxMatches. | 371 // We should have gotten back at most AutocompleteProvider::kMaxMatches. |
371 EXPECT_LE(ac_matches_.size(), AutocompleteProvider::kMaxMatches); | 372 EXPECT_LE(ac_matches_.size(), AutocompleteProvider::kMaxMatches); |
372 | 373 |
373 // If the number of expected and actual matches aren't equal then we need | 374 // If the number of expected and actual matches aren't equal then we need |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 extensions::UnloadedExtensionInfo details( | 845 extensions::UnloadedExtensionInfo details( |
845 extension.get(), extensions::UnloadedExtensionInfo::REASON_UNINSTALL); | 846 extension.get(), extensions::UnloadedExtensionInfo::REASON_UNINSTALL); |
846 content::NotificationService::current()->Notify( | 847 content::NotificationService::current()->Notify( |
847 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 848 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
848 content::Source<Profile>(&profile_), | 849 content::Source<Profile>(&profile_), |
849 content::Details<extensions::UnloadedExtensionInfo>(&details)); | 850 content::Details<extensions::UnloadedExtensionInfo>(&details)); |
850 | 851 |
851 // Now the URL should have disappeared. | 852 // Now the URL should have disappeared. |
852 RunTest(text, false, ExpectedURLs(), std::string(), base::string16()); | 853 RunTest(text, false, ExpectedURLs(), std::string(), base::string16()); |
853 } | 854 } |
OLD | NEW |