~tatokis/unity/gcc-72-errors

« back to all changes in this revision

Viewing changes to tests/test_showdesktop_handler.cpp

  • Committer: Bileto Bot
  • Author(s): Marco Trevisan (Treviño)
  • Date: 2017-09-25 16:03:32 UTC
  • mfrom: (4253.1.17 tests-split-and-cleanup)
  • Revision ID: ci-train-bot@canonical.com-20170925160332-1963tgyjcd41j02e
Tests: split unit tests in single binaries, enable unstable tests

Use CMake foo, for getting the best for running tests in single mode
and generating smart targets for them

Approved by: Andrea Azzarone

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
compiz::WindowInputRemoverInterface::~WindowInputRemoverInterface () {}
15
15
 
 
16
namespace
 
17
{
 
18
const float MAX_FLOAT_DISTANCE = 0.001f;
 
19
}
 
20
 
16
21
class MockWindowInputRemover :
17
22
  public compiz::WindowInputRemoverInterface
18
23
{
405
410
  EXPECT_EQ (ShowdesktopHandler::animating_windows.size (), 1);
406
411
}
407
412
 
408
 
TEST_F(UnityShowdesktopHandlerTest, UNSTABLE_TEST(TestAnimationOpacity))
 
413
TEST_F(UnityShowdesktopHandlerTest, TestAnimationOpacity)
409
414
{
410
415
  MockUnityShowdesktopHandlerWindow mMockWindow;
 
416
  using namespace testing;
411
417
 
412
418
  EXPECT_CALL (mMockWindow, GetInputRemover ()).WillOnce (Invoke (UnityShowdesktopHandlerTest::getLock <MockWindowInputRemoverTestFadeOutFadeIn>));
413
419
  ShowdesktopHandler mMockHandler (static_cast <ShowdesktopHandlerWindowInterface *> (&mMockWindow), static_cast <compiz::WindowInputRemoverLockAcquireInterface *> (&mMockWindow));
431
437
 
432
438
    mMockHandler.Animate (1);
433
439
 
434
 
    if (i == 300)
 
440
    if (i == ShowdesktopHandler::fade_time)
435
441
      EXPECT_EQ (opacity, std::numeric_limits <unsigned short>::max ());
436
442
    else
437
443
    {
438
444
      float rem = opacity - std::numeric_limits <unsigned short>::max () * (1.0f - i / static_cast <float> (ShowdesktopHandler::fade_time));
439
 
      EXPECT_TRUE (rem <= 1.0f && rem >= -1.0f);
 
445
      EXPECT_THAT(rem, AllOf(AnyOf(FloatNear(1.0f, MAX_FLOAT_DISTANCE), Lt(1.0f)),
 
446
                             AnyOf(FloatNear(-1.0f, MAX_FLOAT_DISTANCE), Gt(-1.0f))));
440
447
    }
441
448
  }
442
449
 
449
456
 
450
457
    mMockHandler.Animate (1);
451
458
 
452
 
    if (i == 300)
 
459
    if (i == ShowdesktopHandler::fade_time)
453
460
      EXPECT_EQ (opacity, std::numeric_limits <unsigned short>::max ());
454
461
    else
455
462
    {
456
463
      float rem = opacity - std::numeric_limits <unsigned short>::max () * (i / static_cast <float> (ShowdesktopHandler::fade_time));
457
 
      EXPECT_TRUE (rem <= 1.0f && rem >= -1.0f);
 
464
      EXPECT_THAT(rem, AllOf(AnyOf(FloatNear(1.0f, MAX_FLOAT_DISTANCE), Lt(1.0f)),
 
465
                             AnyOf(FloatNear(-1.0f, MAX_FLOAT_DISTANCE), Gt(-1.0f))));
458
466
    }
459
467
  }
460
468