| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete.h" | 17 #include "chrome/browser/autocomplete/autocomplete.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_match.h" | 18 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 19 #include "chrome/browser/history/history.h" | 19 #include "chrome/browser/history/history.h" |
| 20 #include "chrome/browser/history/in_memory_url_index.h" | 20 #include "chrome/browser/history/in_memory_url_index.h" |
| 21 #include "chrome/browser/history/url_database.h" | 21 #include "chrome/browser/history/url_database.h" |
| 22 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
| 23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/test/base/testing_browser_process.h" | 24 #include "chrome/test/base/testing_browser_process.h" |
| 25 #include "chrome/test/base/testing_browser_process_test.h" | |
| 26 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
| 27 #include "content/browser/browser_thread.h" | 26 #include "content/browser/browser_thread.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 28 |
| 30 using base::Time; | 29 using base::Time; |
| 31 using base::TimeDelta; | 30 using base::TimeDelta; |
| 32 | 31 |
| 33 struct TestShortcutInfo { | 32 struct TestShortcutInfo { |
| 34 std::string url; | 33 std::string url; |
| 35 std::string title; // The text that orginally was searched for. | 34 std::string title; // The text that orginally was searched for. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 "www.daysagotest.com/b.html", "0,1,8,3,11,1", | 87 "www.daysagotest.com/b.html", "0,1,8,3,11,1", |
| 89 "Test - site", "0,0", 1, 2}, | 88 "Test - site", "0,0", 1, 2}, |
| 90 { "http://www.daysagotest.com/c.html", "ago", | 89 { "http://www.daysagotest.com/c.html", "ago", |
| 91 "www.daysagotest.com/c.html", "0,1,8,3,11,1", | 90 "www.daysagotest.com/c.html", "0,1,8,3,11,1", |
| 92 "Test - site", "0,0", 1, 3}, | 91 "Test - site", "0,0", 1, 3}, |
| 93 { "http://www.daysagotest.com/d.html", "ago", | 92 { "http://www.daysagotest.com/d.html", "ago", |
| 94 "www.daysagotest.com/d.html", "0,1,8,3,11,1", | 93 "www.daysagotest.com/d.html", "0,1,8,3,11,1", |
| 95 "Test - site", "0,0", 1, 4}, | 94 "Test - site", "0,0", 1, 4}, |
| 96 }; | 95 }; |
| 97 | 96 |
| 98 class ShortcutsProviderTest : public TestingBrowserProcessTest, | 97 class ShortcutsProviderTest : public testing::Test, |
| 99 public ACProviderListener { | 98 public ACProviderListener { |
| 100 public: | 99 public: |
| 101 ShortcutsProviderTest(); | 100 ShortcutsProviderTest(); |
| 102 | 101 |
| 103 // ACProviderListener | 102 // ACProviderListener |
| 104 virtual void OnProviderUpdate(bool updated_matches); | 103 virtual void OnProviderUpdate(bool updated_matches); |
| 105 | 104 |
| 106 protected: | 105 protected: |
| 107 class SetShouldContain | 106 class SetShouldContain |
| 108 : public std::unary_function<const std::string&, std::set<std::string> > { | 107 : public std::unary_function<const std::string&, std::set<std::string> > { |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 588 |
| 590 match.destination_url = GURL(shortcuts_to_test_delete[2].url); | 589 match.destination_url = GURL(shortcuts_to_test_delete[2].url); |
| 591 match.contents = ASCIIToUTF16(shortcuts_to_test_delete[2].contents); | 590 match.contents = ASCIIToUTF16(shortcuts_to_test_delete[2].contents); |
| 592 match.description = ASCIIToUTF16(shortcuts_to_test_delete[2].description); | 591 match.description = ASCIIToUTF16(shortcuts_to_test_delete[2].description); |
| 593 | 592 |
| 594 provider_->DeleteMatch(match); | 593 provider_->DeleteMatch(match); |
| 595 EXPECT_EQ(original_shortcuts_count, provider_->shortcuts_map_.size()); | 594 EXPECT_EQ(original_shortcuts_count, provider_->shortcuts_map_.size()); |
| 596 EXPECT_TRUE(provider_->shortcuts_map_.end() == | 595 EXPECT_TRUE(provider_->shortcuts_map_.end() == |
| 597 provider_->shortcuts_map_.find(ASCIIToUTF16("delete"))); | 596 provider_->shortcuts_map_.find(ASCIIToUTF16("delete"))); |
| 598 } | 597 } |
| OLD | NEW |