| 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "app/keyboard_codes.h" | 7 #include "app/keyboard_codes.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "views/focus/view_storage.h" | 22 #include "views/focus/view_storage.h" |
| 23 #include "views/view.h" | 23 #include "views/view.h" |
| 24 #include "views/views_delegate.h" | 24 #include "views/views_delegate.h" |
| 25 #include "views/widget/root_view.h" | 25 #include "views/widget/root_view.h" |
| 26 #include "views/window/dialog_delegate.h" | 26 #include "views/window/dialog_delegate.h" |
| 27 #include "views/window/window.h" | 27 #include "views/window/window.h" |
| 28 | 28 |
| 29 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
| 30 #include "views/widget/widget_win.h" | 30 #include "views/widget/widget_win.h" |
| 31 #include "views/controls/button/native_button_win.h" | 31 #include "views/controls/button/native_button_win.h" |
| 32 #include "views/test/test_views_delegate.h" |
| 32 #elif defined(OS_LINUX) | 33 #elif defined(OS_LINUX) |
| 33 #include "views/widget/widget_gtk.h" | 34 #include "views/widget/widget_gtk.h" |
| 34 #include "views/window/window_gtk.h" | 35 #include "views/window/window_gtk.h" |
| 35 #endif | 36 #endif |
| 36 #if defined(TOUCH_UI) | 37 #if defined(TOUCH_UI) |
| 37 #include "views/touchui/gesture_manager.h" | 38 #include "views/touchui/gesture_manager.h" |
| 38 #endif | 39 #endif |
| 39 | 40 |
| 40 using namespace views; | 41 using namespace views; |
| 41 | 42 |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 // Test selection related methods. | 834 // Test selection related methods. |
| 834 textfield->SetText(kText); | 835 textfield->SetText(kText); |
| 835 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); | 836 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); |
| 836 textfield->SelectAll(); | 837 textfield->SelectAll(); |
| 837 EXPECT_EQ(kText, textfield->text()); | 838 EXPECT_EQ(kText, textfield->text()); |
| 838 textfield->ClearSelection(); | 839 textfield->ClearSelection(); |
| 839 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); | 840 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); |
| 840 } | 841 } |
| 841 | 842 |
| 842 #if defined(OS_WIN) | 843 #if defined(OS_WIN) |
| 843 class TestViewsDelegate : public views::ViewsDelegate { | |
| 844 public: | |
| 845 TestViewsDelegate() {} | |
| 846 virtual ~TestViewsDelegate() {} | |
| 847 | |
| 848 // Overridden from views::ViewsDelegate: | |
| 849 virtual ui::Clipboard* GetClipboard() const { | |
| 850 if (!clipboard_.get()) { | |
| 851 // Note that we need a MessageLoop for the next call to work. | |
| 852 clipboard_.reset(new ui::Clipboard); | |
| 853 } | |
| 854 return clipboard_.get(); | |
| 855 } | |
| 856 virtual void SaveWindowPlacement(const std::wstring& window_name, | |
| 857 const gfx::Rect& bounds, | |
| 858 bool maximized) { | |
| 859 } | |
| 860 virtual bool GetSavedWindowBounds(const std::wstring& window_name, | |
| 861 gfx::Rect* bounds) const { | |
| 862 return false; | |
| 863 } | |
| 864 virtual bool GetSavedMaximizedState(const std::wstring& window_name, | |
| 865 bool* maximized) const { | |
| 866 return false; | |
| 867 } | |
| 868 virtual void NotifyAccessibilityEvent( | |
| 869 views::View* view, AccessibilityTypes::Event event_type) {} | |
| 870 virtual HICON GetDefaultWindowIcon() const { | |
| 871 return NULL; | |
| 872 } | |
| 873 virtual void AddRef() {} | |
| 874 virtual void ReleaseRef() {} | |
| 875 | |
| 876 private: | |
| 877 mutable scoped_ptr<ui::Clipboard> clipboard_; | |
| 878 | |
| 879 DISALLOW_COPY_AND_ASSIGN(TestViewsDelegate); | |
| 880 }; | |
| 881 | 844 |
| 882 // Tests that the Textfield view respond appropiately to cut/copy/paste. | 845 // Tests that the Textfield view respond appropiately to cut/copy/paste. |
| 883 TEST_F(ViewTest, TextfieldCutCopyPaste) { | 846 TEST_F(ViewTest, TextfieldCutCopyPaste) { |
| 884 views::ViewsDelegate::views_delegate = new TestViewsDelegate; | 847 views::ViewsDelegate::views_delegate = new TestViewsDelegate; |
| 885 | 848 |
| 886 const std::wstring kNormalText = L"Normal"; | 849 const std::wstring kNormalText = L"Normal"; |
| 887 const std::wstring kReadOnlyText = L"Read only"; | 850 const std::wstring kReadOnlyText = L"Read only"; |
| 888 const std::wstring kPasswordText = L"Password! ** Secret stuff **"; | 851 const std::wstring kPasswordText = L"Password! ** Secret stuff **"; |
| 889 | 852 |
| 890 ui::Clipboard clipboard; | 853 ui::Clipboard clipboard; |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1523 #endif | 1486 #endif |
| 1524 } | 1487 } |
| 1525 | 1488 |
| 1526 TEST_F(ViewTest, ChangeNativeViewHierarchyChangeHierarchy) { | 1489 TEST_F(ViewTest, ChangeNativeViewHierarchyChangeHierarchy) { |
| 1527 // TODO(georgey): Fix the test for Linux | 1490 // TODO(georgey): Fix the test for Linux |
| 1528 #if defined(OS_WIN) | 1491 #if defined(OS_WIN) |
| 1529 TestChangeNativeViewHierarchy test(this); | 1492 TestChangeNativeViewHierarchy test(this); |
| 1530 test.CheckChangingHierarhy(); | 1493 test.CheckChangingHierarhy(); |
| 1531 #endif | 1494 #endif |
| 1532 } | 1495 } |
| OLD | NEW |