| 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/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.h" | 10 #include "chrome/browser/history/history.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 GURL("http://fdsa/") }}, | 98 GURL("http://fdsa/") }}, |
| 99 // The string 'co' appears in one extension app. | 99 // The string 'co' appears in one extension app. |
| 100 {ASCIIToUTF16("co"), 1, { GURL("http://asdf/") }}, | 100 {ASCIIToUTF16("co"), 1, { GURL("http://asdf/") }}, |
| 101 // Try with URL matching. | 101 // Try with URL matching. |
| 102 {ASCIIToUTF16("http://asdf/"), 1, { GURL("http://asdf/") }}, | 102 {ASCIIToUTF16("http://asdf/"), 1, { GURL("http://asdf/") }}, |
| 103 {ASCIIToUTF16("http://fdsa/"), 1, { GURL("http://fdsa/") }}, | 103 {ASCIIToUTF16("http://fdsa/"), 1, { GURL("http://fdsa/") }}, |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 RunTest(edit_cases, ARRAYSIZE_UNSAFE(edit_cases)); | 106 RunTest(edit_cases, ARRAYSIZE_UNSAFE(edit_cases)); |
| 107 } | 107 } |
| 108 |
| 109 TEST_F(ExtensionAppProviderTest, CreateMatchSanitize) { |
| 110 struct TestData { |
| 111 const char* name; |
| 112 const char* match_contents; |
| 113 } cases[] = { |
| 114 { "Test", "Test" }, |
| 115 { "Test \n Test", "Test Test" }, |
| 116 { "Test\r\t\nTest", "TestTest" }, |
| 117 }; |
| 118 |
| 119 AutocompleteInput input(ASCIIToUTF16("Test"), string16(), |
| 120 true, true, true, AutocompleteInput::BEST_MATCH); |
| 121 string16 url(ASCIIToUTF16("http://example.com")); |
| 122 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
| 123 AutocompleteMatch match = |
| 124 app_provider_->CreateAutocompleteMatch(input, |
| 125 ASCIIToUTF16(cases[i].name), |
| 126 url, 0, string16::npos); |
| 127 EXPECT_EQ(ASCIIToUTF16(cases[i].match_contents), match.contents); |
| 128 } |
| 129 } |
| 130 |
| OLD | NEW |