summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-10-06 16:18:18 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-10-06 16:24:15 +0100
commit2ad231f9e90071ad2d83dae7a879ce1295db39ee (patch)
tree77c9a351462459d28558f16949442c31e5ff35ef /vcl/source
parentc43cf1d2b6b6307e9455cbd12bbcd8310e135eac (diff)
experimental afl driven ui testing
Change-Id: I1933951c52adc75ed36db2c083c232f29b6140d6
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/app/svapp.cxx65
1 files changed, 65 insertions, 0 deletions
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 320ea6409e3c..7fb612bed1d9 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -327,11 +327,76 @@ const vcl::KeyCode* Application::GetReservedKeyCode( sal_uLong i )
return &ImplReservedKeys::get()->first[i].mKeyCode;
}
+namespace
+{
+ bool InjectKeyEvent(SvStream& rStream)
+ {
+ VclPtr<vcl::Window> xWin(Application::GetActiveTopWindow());
+ if (!xWin)
+ return false;
+
+ SalKeyEvent aKeyEvent;
+ rStream.ReadUInt64(aKeyEvent.mnTime);
+ rStream.ReadUInt16(aKeyEvent.mnCode);
+ rStream.ReadUInt16(aKeyEvent.mnCharCode);
+ rStream.ReadUInt16(aKeyEvent.mnRepeat);
+ if (!rStream.good())
+ return false;
+
+ ImplWindowFrameProc(xWin.get(), NULL, SALEVENT_KEYINPUT, &aKeyEvent);
+ ImplWindowFrameProc(xWin.get(), NULL, SALEVENT_KEYUP, &aKeyEvent);
+ return true;
+ }
+}
+
+IMPL_LINK_NOARG_TYPED(ImplSVAppData, VclEventTestingHdl, Idle *, void)
+{
+ SAL_INFO("vcl.eventtesting", "EventTestLimit is " << mnEventTestLimit);
+ if (mnEventTestLimit == 0)
+ {
+ delete mpEventTestInput;
+ delete mpEventTestingIdle;
+ SAL_INFO("vcl.eventtesting", "Event Limit reached, exiting" << mnEventTestLimit);
+ Application::Quit();
+ }
+ else
+ {
+ Scheduler::ProcessTaskScheduling(true);
+ if (InjectKeyEvent(*mpEventTestInput))
+ --mnEventTestLimit;
+ if (!mpEventTestInput->good())
+ {
+ delete mpEventTestInput;
+ delete mpEventTestingIdle;
+ SAL_INFO("vcl.eventtesting", "Event Input exhausted, exiting" << mnEventTestLimit);
+ Application::Quit();
+ return;
+ }
+ Scheduler::ProcessTaskScheduling(true);
+ mpEventTestingIdle->Start();
+ }
+}
+
void Application::Execute()
{
ImplSVData* pSVData = ImplGetSVData();
pSVData->maAppData.mbInAppExecute = true;
+ sal_uInt16 n = GetCommandLineParamCount();
+ for (sal_uInt16 i = 0; i != n; ++i)
+ {
+ if (GetCommandLineParam(i) == "--eventtesting")
+ {
+ pSVData->maAppData.mnEventTestLimit = 10;
+ pSVData->maAppData.mpEventTestingIdle = new Idle("eventtesting");
+ pSVData->maAppData.mpEventTestingIdle->SetIdleHdl(LINK(&(pSVData->maAppData), ImplSVAppData, VclEventTestingHdl));
+ pSVData->maAppData.mpEventTestingIdle->SetPriority(SchedulerPriority::LOWEST);
+ pSVData->maAppData.mpEventTestInput = new SvFileStream("eventtesting", StreamMode::READ);
+ pSVData->maAppData.mpEventTestingIdle->Start();
+ break;
+ }
+ }
+
while ( !pSVData->maAppData.mbAppQuit )
Application::Yield();