~dandrader/qtmir/removeHotspot

« back to all changes in this revision

Viewing changes to tests/modules/SessionManager/session_test.cpp

  • Committer: CI Train Bot
  • Author(s): Daniel d'Andrada, Michał Sawicz
  • Date: 2016-05-18 11:18:29 UTC
  • mfrom: (486.1.5 origin/detachPromptSurfaces)
  • Revision ID: ci-train-bot@canonical.com-20160518111829-j8ma5fzus8z2l72h
Move prompt surfaces from MirSurface to Application and emit firstChanged signal

Show diffs side-by-side

added added

removed removed

Lines of Context:
311
311
    EXPECT_EQ(Session::Stopped, session->state());
312
312
    EXPECT_FALSE(session->m_suspendTimer->isRunning());
313
313
}
314
 
 
315
 
/*
316
 
    Regression test for https://bugs.launchpad.net/ubuntu/+source/qtmir/+bug/1578665
317
 
 
318
 
    A child prompt session was arriving before the application surface got a chance to draw
319
 
    its first frame. And on top of that, the application was blocked from drawing anything
320
 
    until that prompt session gone away.
321
 
 */
322
 
TEST_F(SessionTests, ChildSessionArrivesBeforeSurfaceDrawnFirstFrame)
323
 
{
324
 
    using namespace testing;
325
 
 
326
 
    const QString appId("test-app");
327
 
    const pid_t procId = 5551;
328
 
 
329
 
    auto mirSession = std::make_shared<MockSession>(appId.toStdString(), procId);
330
 
 
331
 
    auto session = std::make_shared<qtmir::Session>(mirSession, promptSessionManager);
332
 
 
333
 
    FakeMirSurface *blankSurface = new FakeMirSurface;
334
 
    session->registerSurface(blankSurface);
335
 
 
336
 
    // Surface doesn't appear in this list as it has not drawn its first frame yet
337
 
    EXPECT_EQ(0, session->surfaceList()->count());
338
 
 
339
 
    Session* childSession = new Session(mirSession, promptSessionManager);
340
 
    session->addChildSession(childSession);
341
 
 
342
 
    FakeMirSurface *promptSurface = new FakeMirSurface;
343
 
    childSession->registerSurface(promptSurface);
344
 
    promptSurface->drawFirstFrame();
345
 
 
346
 
    // Even though blankSurface still hasn't drawn its first frame (ie, it's still blank),
347
 
    // it should now appear in this list as it now has a child prompt surface, which the
348
 
    // user must interact with.
349
 
    auto sessionSurfaceList = static_cast<MirSurfaceListModel*>(session->surfaceList());
350
 
    EXPECT_EQ(1, sessionSurfaceList->count());
351
 
    EXPECT_TRUE(sessionSurfaceList->contains(blankSurface));
352
 
 
353
 
    auto promptSurfaceList = static_cast<MirSurfaceListModel*>(blankSurface->promptSurfaceList());
354
 
    EXPECT_EQ(1, promptSurfaceList->count());
355
 
    EXPECT_TRUE(promptSurfaceList->contains(promptSurface));
356
 
}