| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_match.h" | 10 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 12 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "content/public/test/test_browser_thread.h" | 14 #include "content/public/test/test_browser_thread.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/platform_test.h" | 16 #include "testing/platform_test.h" |
| 17 #include "ui/base/gtk/gtk_hig_constants.h" | 17 #include "ui/base/gtk/gtk_hig_constants.h" |
| 18 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
| 19 #include "ui/gfx/rect.h" | |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| 22 class OmniboxEditControllerMock : public OmniboxEditController { | 21 class OmniboxEditControllerMock : public OmniboxEditController { |
| 23 public: | 22 public: |
| 24 MOCK_METHOD4(OnAutocompleteAccept, void(const GURL& url, | 23 MOCK_METHOD4(OnAutocompleteAccept, void(const GURL& url, |
| 25 WindowOpenDisposition disposition, | 24 WindowOpenDisposition disposition, |
| 26 content::PageTransition transition, | 25 content::PageTransition transition, |
| 27 const GURL& alternate_nav_url)); | 26 const GURL& alternate_nav_url)); |
| 28 MOCK_METHOD0(OnChanged, void()); | 27 MOCK_METHOD0(OnChanged, void()); |
| 29 MOCK_METHOD0(OnSelectionBoundsChanged, void()); | 28 MOCK_METHOD0(OnSelectionBoundsChanged, void()); |
| 30 MOCK_METHOD1(OnInputInProgress, void(bool in_progress)); | 29 MOCK_METHOD1(OnInputInProgress, void(bool in_progress)); |
| 31 MOCK_METHOD0(OnKillFocus, void()); | 30 MOCK_METHOD0(OnKillFocus, void()); |
| 32 MOCK_METHOD0(OnSetFocus, void()); | 31 MOCK_METHOD0(OnSetFocus, void()); |
| 33 MOCK_CONST_METHOD0(GetFavicon, gfx::Image()); | 32 MOCK_CONST_METHOD0(GetFavicon, gfx::Image()); |
| 34 MOCK_CONST_METHOD0(GetTitle, string16()); | 33 MOCK_CONST_METHOD0(GetTitle, string16()); |
| 35 MOCK_METHOD0(GetInstant, InstantController*()); | 34 MOCK_METHOD0(GetInstant, InstantController*()); |
| 36 MOCK_CONST_METHOD0(GetWebContents, content::WebContents*()); | 35 MOCK_CONST_METHOD0(GetWebContents, content::WebContents*()); |
| 37 MOCK_CONST_METHOD0(GetOmniboxBounds, gfx::Rect()); | |
| 38 | 36 |
| 39 virtual ~OmniboxEditControllerMock() {} | 37 virtual ~OmniboxEditControllerMock() {} |
| 40 }; | 38 }; |
| 41 } // namespace | 39 } // namespace |
| 42 | 40 |
| 43 class OmniboxViewGtkTest : public PlatformTest { | 41 class OmniboxViewGtkTest : public PlatformTest { |
| 44 public: | 42 public: |
| 45 OmniboxViewGtkTest() : file_thread_(content::BrowserThread::UI) {} | 43 OmniboxViewGtkTest() : file_thread_(content::BrowserThread::UI) {} |
| 46 | 44 |
| 47 virtual void SetUp() { | 45 virtual void SetUp() { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 GtkTextIter i; | 88 GtkTextIter i; |
| 91 const char input[] = " hello, world "; | 89 const char input[] = " hello, world "; |
| 92 const std::string expected = "hello, world"; | 90 const std::string expected = "hello, world"; |
| 93 SetPasteClipboardRequested(true); | 91 SetPasteClipboardRequested(true); |
| 94 view_->OnBeforePossibleChange(); | 92 view_->OnBeforePossibleChange(); |
| 95 gtk_text_buffer_get_iter_at_offset(text_buffer_, &i, 0); | 93 gtk_text_buffer_get_iter_at_offset(text_buffer_, &i, 0); |
| 96 gtk_text_buffer_insert(text_buffer_, &i, input, strlen(input)); | 94 gtk_text_buffer_insert(text_buffer_, &i, input, strlen(input)); |
| 97 | 95 |
| 98 ASSERT_EQ(expected, UTF16ToUTF8(view_->GetText())); | 96 ASSERT_EQ(expected, UTF16ToUTF8(view_->GetText())); |
| 99 } | 97 } |
| OLD | NEW |