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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/test/testing_browser_process_test.h" | 8 #include "chrome/test/testing_browser_process_test.h" |
9 #include "chrome/browser/autocomplete/autocomplete_match.h" | 9 #include "chrome/browser/autocomplete/autocomplete_match.h" |
10 #include "chrome/browser/autocomplete/extension_app_provider.h" | 10 #include "chrome/browser/autocomplete/extension_app_provider.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 void ExtensionAppProviderTest::SetUp() { | 38 void ExtensionAppProviderTest::SetUp() { |
39 profile_.reset(new TestingProfile()); | 39 profile_.reset(new TestingProfile()); |
40 profile_->CreateHistoryService(true, false); | 40 profile_->CreateHistoryService(true, false); |
41 profile_->BlockUntilHistoryProcessesPendingRequests(); | 41 profile_->BlockUntilHistoryProcessesPendingRequests(); |
42 history_service_ = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); | 42 history_service_ = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
43 | 43 |
44 app_provider_ = new ExtensionAppProvider(NULL, profile_.get()); | 44 app_provider_ = new ExtensionAppProvider(NULL, profile_.get()); |
45 | 45 |
46 struct ExtensionApps { | 46 struct ExtensionApps { |
47 std::string app_name; | 47 const char* app_name; |
48 std::string url; | 48 const char* url; |
49 std::string title; | 49 const char* title; |
50 int typed_count; | 50 int typed_count; |
51 } kExtensionApps[] = { | 51 } kExtensionApps[] = { |
52 {"COYB", "http://asdf/", "COYB", 7}, | 52 {"COYB", "http://asdf/", "COYB", 7}, |
53 {"NSNO", "http://fdsa/", "NSNO", 2}, | 53 {"NSNO", "http://fdsa/", "NSNO", 2}, |
54 }; | 54 }; |
55 | 55 |
56 history::URLDatabase* url_db = history_service_->InMemoryDatabase(); | 56 history::URLDatabase* url_db = history_service_->InMemoryDatabase(); |
57 | 57 |
58 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kExtensionApps); ++i) { | 58 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kExtensionApps); ++i) { |
59 // Populate the Extension Apps list. | 59 // Populate the Extension Apps list. |
60 app_provider_->AddExtensionAppForTesting(kExtensionApps[i].app_name, | 60 app_provider_->AddExtensionAppForTesting( |
61 kExtensionApps[i].url); | 61 ASCIIToUTF16(kExtensionApps[i].app_name), |
| 62 ASCIIToUTF16(kExtensionApps[i].url)); |
62 | 63 |
63 // Populate the InMemoryDatabase. | 64 // Populate the InMemoryDatabase. |
64 history::URLRow info(GURL(kExtensionApps[i].url)); | 65 history::URLRow info(GURL(kExtensionApps[i].url)); |
65 info.set_title(UTF8ToUTF16(kExtensionApps[i].title)); | 66 info.set_title(UTF8ToUTF16(kExtensionApps[i].title)); |
66 info.set_typed_count(kExtensionApps[i].typed_count); | 67 info.set_typed_count(kExtensionApps[i].typed_count); |
67 url_db->AddURL(info); | 68 url_db->AddURL(info); |
68 } | 69 } |
69 } | 70 } |
70 | 71 |
71 void ExtensionAppProviderTest::RunTest( | 72 void ExtensionAppProviderTest::RunTest( |
(...skipping 25 matching lines...) Expand all Loading... |
97 GURL("http://fdsa/") }}, | 98 GURL("http://fdsa/") }}, |
98 // The string 'co' appears in one extension app. | 99 // The string 'co' appears in one extension app. |
99 {ASCIIToUTF16("co"), 1, { GURL("http://asdf/") }}, | 100 {ASCIIToUTF16("co"), 1, { GURL("http://asdf/") }}, |
100 // Try with URL matching. | 101 // Try with URL matching. |
101 {ASCIIToUTF16("http://asdf/"), 1, { GURL("http://asdf/") }}, | 102 {ASCIIToUTF16("http://asdf/"), 1, { GURL("http://asdf/") }}, |
102 {ASCIIToUTF16("http://fdsa/"), 1, { GURL("http://fdsa/") }}, | 103 {ASCIIToUTF16("http://fdsa/"), 1, { GURL("http://fdsa/") }}, |
103 }; | 104 }; |
104 | 105 |
105 RunTest(edit_cases, ARRAYSIZE_UNSAFE(edit_cases)); | 106 RunTest(edit_cases, ARRAYSIZE_UNSAFE(edit_cases)); |
106 } | 107 } |
OLD | NEW |