| 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/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 6 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 7 #include "chrome/browser/search_engines/template_url_service_factory.h" | 7 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 8 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 8 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
| 9 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 9 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
| 10 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 10 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 11 #include "chrome/browser/ui/toolbar/test_toolbar_model.h" | 11 #include "chrome/browser/ui/toolbar/test_toolbar_model.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| 15 using base::ASCIIToUTF16; | 16 using base::ASCIIToUTF16; |
| 16 using base::UTF8ToUTF16; | 17 using base::UTF8ToUTF16; |
| 17 using content::WebContents; | 18 using content::WebContents; |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 class TestingOmniboxView : public OmniboxView { | 22 class TestingOmniboxView : public OmniboxView { |
| 22 public: | 23 public: |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 DISALLOW_COPY_AND_ASSIGN(TestingOmniboxEditController); | 122 DISALLOW_COPY_AND_ASSIGN(TestingOmniboxEditController); |
| 122 }; | 123 }; |
| 123 | 124 |
| 124 } // namespace | 125 } // namespace |
| 125 | 126 |
| 126 class AutocompleteEditTest : public ::testing::Test { | 127 class AutocompleteEditTest : public ::testing::Test { |
| 127 public: | 128 public: |
| 128 TestToolbarModel* toolbar_model() { return &toolbar_model_; } | 129 TestToolbarModel* toolbar_model() { return &toolbar_model_; } |
| 129 | 130 |
| 130 private: | 131 private: |
| 132 content::TestBrowserThreadBundle thread_bundle_; |
| 131 TestToolbarModel toolbar_model_; | 133 TestToolbarModel toolbar_model_; |
| 132 }; | 134 }; |
| 133 | 135 |
| 134 // Tests various permutations of AutocompleteModel::AdjustTextForCopy. | 136 // Tests various permutations of AutocompleteModel::AdjustTextForCopy. |
| 135 TEST_F(AutocompleteEditTest, AdjustTextForCopy) { | 137 TEST_F(AutocompleteEditTest, AdjustTextForCopy) { |
| 136 struct Data { | 138 struct Data { |
| 137 const char* perm_text; | 139 const char* perm_text; |
| 138 const int sel_start; | 140 const int sel_start; |
| 139 const bool is_all_selected; | 141 const bool is_all_selected; |
| 140 const char* input; | 142 const char* input; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 251 |
| 250 model.SetUserText(UTF8ToUTF16("he")); | 252 model.SetUserText(UTF8ToUTF16("he")); |
| 251 model.OnPopupDataChanged(UTF8ToUTF16("llo"), NULL, base::string16(), false); | 253 model.OnPopupDataChanged(UTF8ToUTF16("llo"), NULL, base::string16(), false); |
| 252 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); | 254 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); |
| 253 EXPECT_EQ(UTF8ToUTF16("llo"), view.inline_autocomplete_text()); | 255 EXPECT_EQ(UTF8ToUTF16("llo"), view.inline_autocomplete_text()); |
| 254 | 256 |
| 255 model.AcceptTemporaryTextAsUserText(); | 257 model.AcceptTemporaryTextAsUserText(); |
| 256 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); | 258 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); |
| 257 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); | 259 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); |
| 258 } | 260 } |
| OLD | NEW |