| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/ui/app_list/search/chrome_search_result.h" | 11 #include "chrome/browser/ui/app_list/search/chrome_search_result.h" |
| 12 #include "chrome/browser/ui/app_list/search/history_types.h" | 12 #include "chrome/browser/ui/app_list/search/history_types.h" |
| 13 #include "chrome/browser/ui/app_list/search/mixer.h" | 13 #include "chrome/browser/ui/app_list/search/mixer.h" |
| 14 #include "chrome/browser/ui/app_list/search/search_provider.h" | 14 #include "chrome/browser/ui/app_list/search/search_provider.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "ui/app_list/app_list_model.h" | 16 #include "ui/app_list/app_list_model.h" |
| 17 | 17 |
| 18 namespace app_list { | 18 namespace app_list { |
| 19 namespace test { | 19 namespace test { |
| 20 | 20 |
| 21 class TestSearchResult : public ChromeSearchResult { | 21 class TestSearchResult : public ChromeSearchResult { |
| 22 public: | 22 public: |
| 23 TestSearchResult(const std::string& id, double relevance) { | 23 TestSearchResult(const std::string& id, double relevance) { |
| 24 set_id(id); | 24 set_id(id); |
| 25 set_title(UTF8ToUTF16(id)); | 25 set_title(base::UTF8ToUTF16(id)); |
| 26 set_relevance(relevance); | 26 set_relevance(relevance); |
| 27 } | 27 } |
| 28 virtual ~TestSearchResult() {} | 28 virtual ~TestSearchResult() {} |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 // ChromeSearchResult overides: | 31 // ChromeSearchResult overides: |
| 32 virtual void Open(int event_flags) OVERRIDE {} | 32 virtual void Open(int event_flags) OVERRIDE {} |
| 33 virtual void InvokeAction(int action_index, int event_flags) OVERRIDE {} | 33 virtual void InvokeAction(int action_index, int event_flags) OVERRIDE {} |
| 34 virtual scoped_ptr<ChromeSearchResult> Duplicate() OVERRIDE { | 34 virtual scoped_ptr<ChromeSearchResult> Duplicate() OVERRIDE { |
| 35 return scoped_ptr<ChromeSearchResult>( | 35 return scoped_ptr<ChromeSearchResult>( |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 mixer_->MixAndPublish(KnownResults()); | 105 mixer_->MixAndPublish(KnownResults()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 std::string GetResults() const { | 108 std::string GetResults() const { |
| 109 std::string result; | 109 std::string result; |
| 110 for (size_t i = 0; i < results_->item_count(); ++i) { | 110 for (size_t i = 0; i < results_->item_count(); ++i) { |
| 111 if (!result.empty()) | 111 if (!result.empty()) |
| 112 result += ','; | 112 result += ','; |
| 113 | 113 |
| 114 result += UTF16ToUTF8(results_->GetItemAt(i)->title()); | 114 result += base::UTF16ToUTF8(results_->GetItemAt(i)->title()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 return result; | 117 return result; |
| 118 } | 118 } |
| 119 | 119 |
| 120 Mixer* mixer() { return mixer_.get(); } | 120 Mixer* mixer() { return mixer_.get(); } |
| 121 TestSearchProvider* app_provider() { return providers_[0]; } | 121 TestSearchProvider* app_provider() { return providers_[0]; } |
| 122 TestSearchProvider* omnibox_provider() { return providers_[1]; } | 122 TestSearchProvider* omnibox_provider() { return providers_[1]; } |
| 123 TestSearchProvider* webstore_provider() { return providers_[2]; } | 123 TestSearchProvider* webstore_provider() { return providers_[2]; } |
| 124 | 124 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 webstore_provider()->set_count(1); | 178 webstore_provider()->set_count(1); |
| 179 | 179 |
| 180 RunQuery(); | 180 RunQuery(); |
| 181 | 181 |
| 182 // Only three results with unique id are kept. | 182 // Only three results with unique id are kept. |
| 183 EXPECT_EQ("dup0,dup1,dup2", GetResults()); | 183 EXPECT_EQ("dup0,dup1,dup2", GetResults()); |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace test | 186 } // namespace test |
| 187 } // namespace app_list | 187 } // namespace app_list |
| OLD | NEW |