| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/autocomplete/autocomplete_match.h" | 8 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 9 #include "chrome/browser/autocomplete/extension_app_provider.h" | 9 #include "chrome/browser/autocomplete/extension_app_provider.h" |
| 10 #include "chrome/browser/history/history_service.h" | 10 #include "chrome/browser/history/history_service.h" |
| 11 #include "chrome/browser/history/history_service_factory.h" | 11 #include "chrome/browser/history/history_service_factory.h" |
| 12 #include "chrome/browser/history/url_database.h" | 12 #include "chrome/browser/history/url_database.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "content/public/test/test_browser_thread.h" | 14 #include "content/public/test/test_browser_thread.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 using base::ASCIIToUTF16; |
| 18 |
| 17 class ExtensionAppProviderTest : public testing::Test { | 19 class ExtensionAppProviderTest : public testing::Test { |
| 18 protected: | 20 protected: |
| 19 struct test_data { | 21 struct test_data { |
| 20 const base::string16 input; | 22 const base::string16 input; |
| 21 const size_t num_results; | 23 const size_t num_results; |
| 22 const GURL output[3]; | 24 const GURL output[3]; |
| 23 }; | 25 }; |
| 24 | 26 |
| 25 ExtensionAppProviderTest() | 27 ExtensionAppProviderTest() |
| 26 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 28 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // Populate the Extension Apps list. | 70 // Populate the Extension Apps list. |
| 69 ExtensionAppProvider::ExtensionApp extension_app = { | 71 ExtensionAppProvider::ExtensionApp extension_app = { |
| 70 ASCIIToUTF16(kExtensionApps[i].app_name), | 72 ASCIIToUTF16(kExtensionApps[i].app_name), |
| 71 ASCIIToUTF16(kExtensionApps[i].launch_url), | 73 ASCIIToUTF16(kExtensionApps[i].launch_url), |
| 72 kExtensionApps[i].should_match_against_launch_url | 74 kExtensionApps[i].should_match_against_launch_url |
| 73 }; | 75 }; |
| 74 app_provider_->AddExtensionAppForTesting(extension_app); | 76 app_provider_->AddExtensionAppForTesting(extension_app); |
| 75 | 77 |
| 76 // Populate the InMemoryDatabase. | 78 // Populate the InMemoryDatabase. |
| 77 history::URLRow info(GURL(kExtensionApps[i].launch_url)); | 79 history::URLRow info(GURL(kExtensionApps[i].launch_url)); |
| 78 info.set_title(UTF8ToUTF16(kExtensionApps[i].title)); | 80 info.set_title(base::UTF8ToUTF16(kExtensionApps[i].title)); |
| 79 info.set_typed_count(kExtensionApps[i].typed_count); | 81 info.set_typed_count(kExtensionApps[i].typed_count); |
| 80 url_db->AddURL(info); | 82 url_db->AddURL(info); |
| 81 } | 83 } |
| 82 } | 84 } |
| 83 | 85 |
| 84 void ExtensionAppProviderTest::RunTest( | 86 void ExtensionAppProviderTest::RunTest( |
| 85 test_data* keyword_cases, | 87 test_data* keyword_cases, |
| 86 int num_cases) { | 88 int num_cases) { |
| 87 ACMatches matches; | 89 ACMatches matches; |
| 88 for (int i = 0; i < num_cases; ++i) { | 90 for (int i = 0; i < num_cases; ++i) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 ExtensionAppProvider::ExtensionApp extension_app = | 148 ExtensionAppProvider::ExtensionApp extension_app = |
| 147 {ASCIIToUTF16(cases[i].name), url, true}; | 149 {ASCIIToUTF16(cases[i].name), url, true}; |
| 148 AutocompleteMatch match = | 150 AutocompleteMatch match = |
| 149 app_provider_->CreateAutocompleteMatch(input, | 151 app_provider_->CreateAutocompleteMatch(input, |
| 150 extension_app, | 152 extension_app, |
| 151 0, | 153 0, |
| 152 base::string16::npos); | 154 base::string16::npos); |
| 153 EXPECT_EQ(ASCIIToUTF16(cases[i].match_contents), match.contents); | 155 EXPECT_EQ(ASCIIToUTF16(cases[i].match_contents), match.contents); |
| 154 } | 156 } |
| 155 } | 157 } |
| OLD | NEW |