| 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 <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1859 browser()->toolbar_model()->set_url_replacement_enabled(false); | 1859 browser()->toolbar_model()->set_url_replacement_enabled(false); |
| 1860 test_toolbar_model->set_text(url_b); | 1860 test_toolbar_model->set_text(url_b); |
| 1861 omnibox_view->Update(); | 1861 omnibox_view->Update(); |
| 1862 EXPECT_EQ(url_a, omnibox_view->GetText()); | 1862 EXPECT_EQ(url_a, omnibox_view->GetText()); |
| 1863 omnibox_view->RevertAll(); | 1863 omnibox_view->RevertAll(); |
| 1864 EXPECT_EQ(url_b, omnibox_view->GetText()); | 1864 EXPECT_EQ(url_b, omnibox_view->GetText()); |
| 1865 test_toolbar_model->set_text(url_c); | 1865 test_toolbar_model->set_text(url_c); |
| 1866 omnibox_view->Update(); | 1866 omnibox_view->Update(); |
| 1867 EXPECT_EQ(url_c, omnibox_view->GetText()); | 1867 EXPECT_EQ(url_c, omnibox_view->GetText()); |
| 1868 } | 1868 } |
| 1869 |
| 1870 // Test that if the Omnibox has focus, and had everything selected before a |
| 1871 // non-user-initiated update, then it retains the selection after the update. |
| 1872 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, SelectAllStaysAfterUpdate) { |
| 1873 OmniboxView* omnibox_view = nullptr; |
| 1874 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
| 1875 TestToolbarModel* test_toolbar_model = new TestToolbarModel; |
| 1876 scoped_ptr<ToolbarModel> toolbar_model(test_toolbar_model); |
| 1877 browser()->swap_toolbar_models(&toolbar_model); |
| 1878 |
| 1879 base::string16 url_a(ASCIIToUTF16("http://www.a.com/")); |
| 1880 base::string16 url_b(ASCIIToUTF16("http://www.b.com/")); |
| 1881 chrome::FocusLocationBar(browser()); |
| 1882 |
| 1883 test_toolbar_model->set_text(url_a); |
| 1884 omnibox_view->Update(); |
| 1885 EXPECT_EQ(url_a, omnibox_view->GetText()); |
| 1886 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| 1887 |
| 1888 // Updating while selected should retain SelectAll(). |
| 1889 test_toolbar_model->set_text(url_b); |
| 1890 omnibox_view->Update(); |
| 1891 EXPECT_EQ(url_b, omnibox_view->GetText()); |
| 1892 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
| 1893 |
| 1894 // Select nothing, then switch back. Shouldn't gain a selection. |
| 1895 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RIGHT, 0)); |
| 1896 test_toolbar_model->set_text(url_a); |
| 1897 omnibox_view->Update(); |
| 1898 EXPECT_EQ(url_a, omnibox_view->GetText()); |
| 1899 EXPECT_FALSE(omnibox_view->IsSelectAll()); |
| 1900 } |
| OLD | NEW |