blob: 201c47180ecaa529df6099d7e158da5c8cf9e751 [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
#pragma GCC diagnostic push
#include <Weave/DeviceLayer/PlatformManager.h>
#include <Weave/DeviceLayer/internal/WeaveDeviceLayerInternal.h>
#pragma GCC diagnostic pop
// clang-format on
#include "src/connectivity/weave/adaptation/platform_manager_impl.h"
#include "src/lib/testing/loop_fixture/test_loop_fixture.h"
namespace weave::adaptation::testing {
namespace {
using nl::Weave::DeviceLayer::PlatformMgr;
using nl::Weave::DeviceLayer::PlatformMgrImpl;
} // namespace
class PlatformManagerTest : public ::gtest::TestLoopFixture {
public:
void SetUp() override { PlatformMgrImpl().SetDispatcher(dispatcher()); }
};
TEST_F(PlatformManagerTest, ScheduleWork) {
size_t counter = 0;
auto increment_counter = [](intptr_t context) { (*reinterpret_cast<size_t*>(context))++; };
PlatformMgr().ScheduleWork(increment_counter, reinterpret_cast<intptr_t>(&counter));
RunLoopUntilIdle();
EXPECT_EQ(counter, 1U);
PlatformMgr().ScheduleWork(increment_counter, reinterpret_cast<intptr_t>(&counter));
PlatformMgr().ScheduleWork(increment_counter, reinterpret_cast<intptr_t>(&counter));
RunLoopUntilIdle();
EXPECT_EQ(counter, 3U);
}
} // namespace weave::adaptation::testing