~mandel/unity/fix-autopilot

« back to all changes in this revision

Viewing changes to tests/test_pointer_barrier.cpp

  • Committer: Tarmac
  • Author(s): Brandon Schaefer
  • Date: 2013-07-10 14:03:21 UTC
  • mfrom: (3414.3.1 uni)
  • Revision ID: tarmac-20130710140321-mzuvbqxw6jis33oo
Don't calculate the velocity if dtime is 0. This way we don't get a huge velocity on the initial barrier hit. Fixes: https://bugs.launchpad.net/bugs/1199050.

Approved by Stephen M. Webb, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
 
22
22
#include <gtest/gtest.h>
 
23
#include <gmock/gmock.h>
 
24
using namespace testing;
 
25
 
23
26
#include <limits>
24
27
 
25
28
#include "test_utils.h"
34
37
{
35
38
public:
36
39
  bool HandleBarrierEvent(XIBarrierEvent* b_ev) { return PointerBarrierWrapper::HandleBarrierEvent(b_ev); }
 
40
 
 
41
  MOCK_METHOD1(ReleaseBarrier, void(int));
37
42
};
38
43
 
39
44
XIBarrierEvent GetGenericEvent (unsigned int id)
162
167
  EXPECT_EQ(events_recived, 2);
163
168
}
164
169
 
 
170
TEST(TestPointerBarrier, DontReleaseBarrierOnEmptyDTime)
 
171
{
 
172
  MockPointerBarrier pb;
 
173
  pb.threshold = 1000;
 
174
  XIBarrierEvent ev = GetGenericEvent(0xabba);
 
175
  ev.dtime = 0;
 
176
 
 
177
  {
 
178
    InSequence sequence;
 
179
    EXPECT_CALL(pb, ReleaseBarrier(0xabba)).Times(0);
 
180
  }
 
181
 
 
182
  EXPECT_TRUE(pb.HandleBarrierEvent(&ev));
 
183
 
 
184
  Utils::WaitForTimeoutMSec(pb.smoothing());
 
185
}
 
186
 
 
187
TEST(TestPointerBarrier, ReleaseBarrierIfOverThreshold)
 
188
{
 
189
  MockPointerBarrier pb;
 
190
  pb.threshold = 500;
 
191
  XIBarrierEvent ev = GetGenericEvent(0xabba);
 
192
 
 
193
  {
 
194
    InSequence sequence;
 
195
    EXPECT_CALL(pb, ReleaseBarrier(0xabba)).Times(1);
 
196
  }
 
197
 
 
198
  EXPECT_TRUE(pb.HandleBarrierEvent(&ev));
 
199
 
 
200
  Utils::WaitForTimeoutMSec(pb.smoothing());
 
201
}
 
202
 
165
203
}