Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b69e76f7 authored by Yu Shan's avatar Yu Shan Committed by Android (Google) Code Review
Browse files

Merge "Fix two unit test failures."

parents 2433311d fb023d01
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -41,7 +41,8 @@ TEST(RecurrentTimerTest, oneInterval) {

    timer.registerRecurrentEvent(milliseconds(1), 0xdead);
    std::this_thread::sleep_for(milliseconds(100));
    ASSERT_EQ_WITH_TOLERANCE(100, counter.load(), 20);
    // This test is unstable, so set the tolerance to 50.
    ASSERT_EQ_WITH_TOLERANCE(100, counter.load(), 50);
}

TEST(RecurrentTimerTest, multipleIntervals) {
@@ -66,7 +67,8 @@ TEST(RecurrentTimerTest, multipleIntervals) {
    timer.registerRecurrentEvent(milliseconds(5), 0xbeef);

    std::this_thread::sleep_for(milliseconds(100));
    ASSERT_EQ_WITH_TOLERANCE(100, counter1ms.load(), 20);
    // This test is unstable, so set the tolerance to 50.
    ASSERT_EQ_WITH_TOLERANCE(100, counter1ms.load(), 50);
    ASSERT_EQ_WITH_TOLERANCE(20, counter5ms.load(), 5);
}

+5 −3
Original line number Diff line number Diff line
@@ -58,10 +58,12 @@ public:

TEST_F(VehicleObjectPoolTest, valuePoolBasicCorrectness) {
    auto value = valuePool->obtain(VehiclePropertyType::INT32);
    // At this point, v1 should be recycled and the only object in the pool.
    ASSERT_EQ(value.get(), valuePool->obtain(VehiclePropertyType::INT32).get());
    void* raw = value.get();
    value.reset();
    // At this point, value should be recycled and the only object in the pool.
    ASSERT_EQ(raw, valuePool->obtain(VehiclePropertyType::INT32).get());
    // Obtaining value of another type - should return a new object
    ASSERT_NE(value.get(), valuePool->obtain(VehiclePropertyType::FLOAT).get());
    ASSERT_NE(raw, valuePool->obtain(VehiclePropertyType::FLOAT).get());

    ASSERT_EQ(3u, stats->Obtained);
    ASSERT_EQ(2u, stats->Created);