[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] A GUI test for pasting
From: |
Greg Chicares |
Subject: |
Re: [lmi] A GUI test for pasting |
Date: |
Sun, 03 Feb 2008 15:46:32 +0000 |
User-agent: |
Thunderbird 2.0.0.9 (Windows/20071031) |
On 2008-02-02 20:54Z, Vadim Zeitlin wrote:
> On Sat, 02 Feb 2008 20:34:43 +0000 Greg Chicares <address@hidden> wrote:
>
> GC> Vadim, would you please look at this change I just made:
> GC> http://cvs.sv.gnu.org/viewvc/lmi/lmi/main_wx.cpp?r1=1.91&r2=1.92
[...]
> [...] In this particular case you could
> write the test working only under wxMSW using MSW-specific code (e.g.
> ::SendMessage(GetHwndOf(some_text_control), WM_PASTE, 0, 0)) but this is
> not really acceptable because not only it leaves other platforms untested
> but it's also difficult to generalize to other cases.
It's not at all ideal. But OTOH I don't ever want to see this
problem again, except in a unit test that informs me cheaply
and early. This is nongnu.org, and we avoid writing code that
works better under msw than under a free OS; but we can test an
msw-specific problem by msw-specific means.
(All the better if you can propose a gtk-specific kludge that
tests something similar--and I plan to expand the test to
encompass a "text/plain" example as well (even though that
will only prove that the wxEVT_COMMAND_TEXT_PASTE handler
correctly skips the event). That can come after msw.)
But I can't get it to work yet. With ::SendMessage(), I reach
the last test in Skeleton::UponPaste(), but return early because
that test fails:
wxTextDataObject test_data;
if(!wxTheClipboard->GetData(test_data))
{
+ warning() << "Early return." << LMI_FLUSH;
return;
}
I think that's because the clipboard contains only a spreadsheet
reference, but no actual content. So I tried adding some text
data to the data object, taking it from my original report:
http://lists.nongnu.org/archive/html/lmi/2008-02/msg00000.html
| 0000120 i g i n a l sp s t r i n g : cr nl
| 0000140 1 cr cr nl 2 cr cr nl 3 cr cr nl cr nl * *
and adjusting the spreadsheet reference accordingly, as in the
experimental patch below [1].
I'd really like this to work, but I'm badly stuck. Could I ask
you to write a patch that successfully tests pasting as if from
ms 'excel'?
---------
[1] Here's what I've tried:
Index: main_wx.cpp
===================================================================
RCS file: /sources/lmi/lmi/main_wx.cpp,v
retrieving revision 1.92
diff -u -2 -r1.92 main_wx.cpp
--- main_wx.cpp 2 Feb 2008 20:22:32 -0000 1.92
+++ main_wx.cpp 3 Feb 2008 15:28:45 -0000
@@ -795,4 +795,5 @@
if(!wxTheClipboard->GetData(test_data))
{
+warning() << "Early return" << LMI_FLUSH;
return;
}
@@ -942,8 +943,10 @@
{
// Put sample data onto the clipboard.
- wxString s("Excel\0[Book1]Sheet1\0R1C2:R7C2\0\0");
+ wxString s("Excel\0[Book1]Sheet1\0R1C1:R3C1\0\0");
wxDataFormat df("Link");
wxCustomDataObject* x = new wxCustomDataObject(df);
x->SetData(s.length(), s.c_str());
+ char const* p = "\r\n1\r\r\n2\r\r\n3\r\r\n\r\n\0\0\0\0";
+ x->SetData(wxDataFormat(wxDF_TEXT), 20, p);
wxTheClipboard->AddData(x);
@@ -954,4 +957,6 @@
wxPostEvent(t, e);
wxYield();
+ HWND handle = reinterpret_cast<HWND>(t->GetHandle());
+ ::SendMessage(handle, WM_PASTE, 0, 0);
warning()