| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 6 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 7 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" | 7 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" |
| 8 #include "chrome/test/testing_browser_process.h" |
| 8 #include "chrome/test/testing_profile.h" | 9 #include "chrome/test/testing_profile.h" |
| 9 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 class TestingAutocompleteEditView : public AutocompleteEditView { | 15 class TestingAutocompleteEditView : public AutocompleteEditView { |
| 15 public: | 16 public: |
| 16 TestingAutocompleteEditView() {} | 17 TestingAutocompleteEditView() {} |
| 17 | 18 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // Tests that http:// isn't inserted for an https url after the user nukes | 134 // Tests that http:// isn't inserted for an https url after the user nukes |
| 134 // https. | 135 // https. |
| 135 { "https://a.com/", 0, false, "a.com/", "a.com/", false, "" }, | 136 { "https://a.com/", 0, false, "a.com/", "a.com/", false, "" }, |
| 136 | 137 |
| 137 // Tests that http:// isn't inserted if the user adds to the host. | 138 // Tests that http:// isn't inserted if the user adds to the host. |
| 138 { "a.b/", 0, false, "a.bc/", "a.bc/", false, "" }, | 139 { "a.b/", 0, false, "a.bc/", "a.bc/", false, "" }, |
| 139 | 140 |
| 140 // Tests that we don't get double http if the user manually inserts http. | 141 // Tests that we don't get double http if the user manually inserts http. |
| 141 { "a.b/", 0, false, "http://a.b/", "http://a.b/", true, "http://a.b/" }, | 142 { "a.b/", 0, false, "http://a.b/", "http://a.b/", true, "http://a.b/" }, |
| 142 }; | 143 }; |
| 144 ScopedTestingBrowserProcess browser_process; |
| 143 TestingAutocompleteEditView view; | 145 TestingAutocompleteEditView view; |
| 144 TestingAutocompleteEditController controller; | 146 TestingAutocompleteEditController controller; |
| 145 TestingProfile profile; | 147 TestingProfile profile; |
| 146 AutocompleteEditModel model(&view, &controller, &profile); | 148 AutocompleteEditModel model(&view, &controller, &profile); |
| 147 | 149 |
| 148 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input); ++i) { | 150 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input); ++i) { |
| 149 model.UpdatePermanentText(ASCIIToUTF16(input[i].perm_text)); | 151 model.UpdatePermanentText(ASCIIToUTF16(input[i].perm_text)); |
| 150 | 152 |
| 151 string16 result = ASCIIToUTF16(input[i].input); | 153 string16 result = ASCIIToUTF16(input[i].input); |
| 152 GURL url; | 154 GURL url; |
| 153 bool write_url; | 155 bool write_url; |
| 154 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected, | 156 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected, |
| 155 &result, &url, &write_url); | 157 &result, &url, &write_url); |
| 156 EXPECT_EQ(ASCIIToUTF16(input[i].expected_output), result) << "@: " << i; | 158 EXPECT_EQ(ASCIIToUTF16(input[i].expected_output), result) << "@: " << i; |
| 157 EXPECT_EQ(input[i].write_url, write_url) << " @" << i; | 159 EXPECT_EQ(input[i].write_url, write_url) << " @" << i; |
| 158 if (write_url) | 160 if (write_url) |
| 159 EXPECT_EQ(input[i].expected_url, url.spec()) << " @" << i; | 161 EXPECT_EQ(input[i].expected_url, url.spec()) << " @" << i; |
| 160 } | 162 } |
| 161 } | 163 } |
| OLD | NEW |