summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 22:46:15 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 22:46:15 +0000
commita280e79f6dafe5c844df05b2c5b96715c98f3a96 (patch)
tree9b11ce6628682e3490ae5b9b299e6b86d04597b1 /views
parent8abe68cddc89ad000515c3314ec332fb007f437b (diff)
downloadchromium_src-a280e79f6dafe5c844df05b2c5b96715c98f3a96.zip
chromium_src-a280e79f6dafe5c844df05b2c5b96715c98f3a96.tar.gz
chromium_src-a280e79f6dafe5c844df05b2c5b96715c98f3a96.tar.bz2
Fix the View cut/copy/paste tests for clipboard. The views delegate wasn't attached so the textfield couldn't access the clipboard to write to it on copy. Create a mock views delegate for this test so that the textfield can get a clipboard.
BUG=none TEST=duh. Review URL: http://codereview.chromium.org/118487 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18104 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/view_unittest.cc43
1 files changed, 42 insertions, 1 deletions
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 5dfa688..6484653 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -19,6 +19,7 @@
#include "views/event.h"
#include "views/focus/view_storage.h"
#include "views/view.h"
+#include "views/views_delegate.h"
#include "views/widget/root_view.h"
#include "views/widget/widget_win.h"
#include "views/window/dialog_delegate.h"
@@ -600,8 +601,45 @@ TEST_F(ViewTest, HitTestMasks) {
}
#if defined(OS_WIN)
+class TestViewsDelegate : public views::ViewsDelegate {
+ public:
+ TestViewsDelegate() {}
+ virtual ~TestViewsDelegate() {}
+
+ // Overridden from views::ViewsDelegate:
+ virtual Clipboard* GetClipboard() const {
+ if (!clipboard_.get()) {
+ // Note that we need a MessageLoop for the next call to work.
+ clipboard_.reset(new Clipboard);
+ }
+ return clipboard_.get();
+ }
+ virtual void SaveWindowPlacement(const std::wstring& window_name,
+ const gfx::Rect& bounds,
+ bool maximized) {
+ }
+ virtual bool GetSavedWindowBounds(const std::wstring& window_name,
+ gfx::Rect* bounds) const {
+ return false;
+ }
+ virtual bool GetSavedMaximizedState(const std::wstring& window_name,
+ bool* maximized) const {
+ return false;
+ }
+ virtual HICON GetDefaultWindowIcon() const {
+ return NULL;
+ }
+
+ private:
+ mutable scoped_ptr<Clipboard> clipboard_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestViewsDelegate);
+};
+
// Tests that the Textfield view respond appropiately to cut/copy/paste.
-TEST_F(ViewTest, DISABLED_TextfieldCutCopyPaste) {
+TEST_F(ViewTest, TextfieldCutCopyPaste) {
+ views::ViewsDelegate::views_delegate = new TestViewsDelegate;
+
const std::wstring kNormalText = L"Normal";
const std::wstring kReadOnlyText = L"Read only";
const std::wstring kPasswordText = L"Password! ** Secret stuff **";
@@ -706,6 +744,9 @@ TEST_F(ViewTest, DISABLED_TextfieldCutCopyPaste) {
::SendMessage(normal->GetTestingHandle(), WM_PASTE, 0, 0);
::GetWindowText(normal->GetTestingHandle(), buffer, 1024);
EXPECT_EQ(kReadOnlyText, std::wstring(buffer));
+
+ delete views::ViewsDelegate::views_delegate;
+ views::ViewsDelegate::views_delegate = NULL;
}
#endif