Chromium Code Reviews| 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/clipboard/clipboard.h" | 7 #include "app/clipboard/clipboard.h" |
| 8 #include "app/keyboard_codes.h" | 8 #include "app/keyboard_codes.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 803 // Test selection related methods. | 804 // Test selection related methods. |
| 804 textfield->SetText(kText); | 805 textfield->SetText(kText); |
| 805 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); | 806 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); |
| 806 textfield->SelectAll(); | 807 textfield->SelectAll(); |
| 807 EXPECT_EQ(kText, textfield->text()); | 808 EXPECT_EQ(kText, textfield->text()); |
| 808 textfield->ClearSelection(); | 809 textfield->ClearSelection(); |
| 809 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); | 810 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); |
| 810 } | 811 } |
| 811 | 812 |
| 812 #if defined(OS_WIN) | 813 #if defined(OS_WIN) |
| 813 class TestViewsDelegate : public views::ViewsDelegate { | |
| 814 public: | |
| 815 TestViewsDelegate() {} | |
| 816 virtual ~TestViewsDelegate() {} | |
| 817 | |
| 818 // Overridden from views::ViewsDelegate: | |
| 819 virtual Clipboard* GetClipboard() const { | |
| 820 if (!clipboard_.get()) { | |
| 821 // Note that we need a MessageLoop for the next call to work. | |
| 822 clipboard_.reset(new Clipboard); | |
| 823 } | |
| 824 return clipboard_.get(); | |
| 825 } | |
| 826 virtual void SaveWindowPlacement(const std::wstring& window_name, | |
| 827 const gfx::Rect& bounds, | |
| 828 bool maximized) { | |
| 829 } | |
| 830 virtual bool GetSavedWindowBounds(const std::wstring& window_name, | |
| 831 gfx::Rect* bounds) const { | |
| 832 return false; | |
| 833 } | |
| 834 virtual bool GetSavedMaximizedState(const std::wstring& window_name, | |
| 835 bool* maximized) const { | |
| 836 return false; | |
| 837 } | |
| 838 virtual void NotifyAccessibilityEvent( | |
| 839 views::View* view, AccessibilityTypes::Event event_type) {} | |
| 840 virtual HICON GetDefaultWindowIcon() const { | |
| 841 return NULL; | |
| 842 } | |
| 843 virtual void AddRef() {} | |
| 844 virtual void ReleaseRef() {} | |
| 845 | |
| 846 private: | |
| 847 mutable scoped_ptr<Clipboard> clipboard_; | |
| 848 | |
| 849 DISALLOW_COPY_AND_ASSIGN(TestViewsDelegate); | |
| 850 }; | |
|
oshima
2011/01/05 18:50:30
There are more in
bookmark_bar_view_test.cc, acces
| |
| 851 | 814 |
| 852 // Tests that the Textfield view respond appropiately to cut/copy/paste. | 815 // Tests that the Textfield view respond appropiately to cut/copy/paste. |
| 853 TEST_F(ViewTest, TextfieldCutCopyPaste) { | 816 TEST_F(ViewTest, TextfieldCutCopyPaste) { |
| 854 views::ViewsDelegate::views_delegate = new TestViewsDelegate; | 817 views::ViewsDelegate::views_delegate = new TestViewsDelegate; |
| 855 | 818 |
| 856 const std::wstring kNormalText = L"Normal"; | 819 const std::wstring kNormalText = L"Normal"; |
| 857 const std::wstring kReadOnlyText = L"Read only"; | 820 const std::wstring kReadOnlyText = L"Read only"; |
| 858 const std::wstring kPasswordText = L"Password! ** Secret stuff **"; | 821 const std::wstring kPasswordText = L"Password! ** Secret stuff **"; |
| 859 | 822 |
| 860 Clipboard clipboard; | 823 Clipboard clipboard; |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1493 #endif | 1456 #endif |
| 1494 } | 1457 } |
| 1495 | 1458 |
| 1496 TEST_F(ViewTest, ChangeNativeViewHierarchyChangeHierarchy) { | 1459 TEST_F(ViewTest, ChangeNativeViewHierarchyChangeHierarchy) { |
| 1497 // TODO(georgey): Fix the test for Linux | 1460 // TODO(georgey): Fix the test for Linux |
| 1498 #if defined(OS_WIN) | 1461 #if defined(OS_WIN) |
| 1499 TestChangeNativeViewHierarchy test(this); | 1462 TestChangeNativeViewHierarchy test(this); |
| 1500 test.CheckChangingHierarhy(); | 1463 test.CheckChangingHierarhy(); |
| 1501 #endif | 1464 #endif |
| 1502 } | 1465 } |
| OLD | NEW |