~mir-team/qtmir/devel-mir-next

Viewing all changes in revision 459.

  • Committer: CI Train Bot
  • Author(s): Michael Terry
  • Date: 2016-03-10 09:29:31 UTC
  • mfrom: (422.2.4 more-accurate-mocks)
  • Revision ID: ci-train-bot@canonical.com-20160310092931-4vre33rtznegzjgn
Fix some mocks to use more realistic code paths.

Specifically, MockApplicationController::doAppIdHasProcessId() was returning -1 if the appId was unknown.  But that function returns a bool, so the -1 got translated into a true value.  So that mocked method returned true for appIds that hadn't been registered yet.

In order to fix that, I decided to rewrite doAppIdHasProcessId to call primaryPidForAppId so that it could be overridden easier in tests.  And adjusted the affected tests to all set an ON_CALL(primaryPidForAppId).

(Because otherwise the test has no way to influence the pid used for children -- why do we actually fork off a while(true) process?)

There are several other fixes here for pieces of the mocks that I found were missing while exploring solutions for the above problem:

- I'm actually not 100% clear on why this started being called, but MockSession::name() couldn't create a default value for QString and the gtest framework was bailing when it was called.  So I added a default.

- Similarly, if ApplicationManager::authorizeSession() tries to examine an app's commandline, gtest will abort because MockProcInfo::command_line() doesn't have a mock return value.  So I added a default.

- And if authorizeSession() lasted long enough to see that the Application object already existed, it deleted the desktop reader object it had made.  But the test mocks always returned the same object, so this caused a segfault.  I retooled the ApplicationManager tests to return a new object each time DesktopFileReaderFactory::createInstance was called.
Approved by: Gerry Boland, Unity8 CI Bot

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: