~dandrader/qtmir/coordinateTranslator

« back to all changes in this revision

Viewing changes to tests/modules/Application/application_test.cpp

  • Committer: CI Train Bot
  • Author(s): Daniel d'Andrada
  • Date: 2016-05-20 08:41:17 UTC
  • mfrom: (482.2.2 bogusRespawn-lp1575577)
  • Revision ID: ci-train-bot@canonical.com-20160520084117-uj7qmbt7dd1mwdnk
Application: Don't respawn if closed while still starting up

+ refactoring of Application::onSessionStateChanged to explicitly cover every single internal state on session stopping. Fixes: #1575577
Approved by: Gerry Boland, Unity8 CI Bot, Michael Terry

Show diffs side-by-side

added added

removed removed

Lines of Context:
589
589
 
590
590
    EXPECT_EQ(Application::InternalState::StoppedResumable, application->internalState());
591
591
}
 
592
 
 
593
/*
 
594
   Regression test for bug "App respawns if manually closed while it's launching"
 
595
   https://bugs.launchpad.net/ubuntu/+source/qtmir/+bug/1575577
 
596
 */
 
597
TEST_F(ApplicationTests, dontRespawnIfClosedWhileStillStartingUp)
 
598
{
 
599
    using namespace ::testing;
 
600
 
 
601
    QScopedPointer<Application> application(createApplicationWithFakes());
 
602
 
 
603
    application->setProcessState(Application::ProcessRunning);
 
604
 
 
605
    FakeSession *session = new FakeSession;
 
606
 
 
607
    application->setSession(session);
 
608
 
 
609
    QSignalSpy spyStartProcess(application.data(), SIGNAL(startProcessRequested()));
 
610
 
 
611
    // Close the application before it even gets a surface (it's still in "starting" state)
 
612
    application->close();
 
613
 
 
614
    session->setState(SessionInterface::Stopped);
 
615
 
 
616
    EXPECT_EQ(Application::InternalState::Stopped, application->internalState());
 
617
    EXPECT_EQ(0, spyStartProcess.count());
 
618
}