// Copyright 2021-2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "sharing/internal/test/fake_context.h" #include #include #include "internal/platform/clock.h" #include "internal/platform/task_runner.h" #include "internal/platform/timer.h" #include "internal/test/fake_clock.h" #include "internal/test/fake_task_runner.h" #include "internal/test/fake_timer.h" #include "sharing/internal/api/bluetooth_adapter.h" #include "sharing/internal/api/fast_initiation_manager.h" #include "sharing/internal/public/connectivity_manager.h" #include "sharing/internal/test/fake_bluetooth_adapter.h" #include "sharing/internal/test/fake_connectivity_manager.h" #include "sharing/internal/test/fake_fast_initiation_manager.h" namespace nearby { FakeContext::FakeContext() : fake_clock_(std::make_unique()), fake_connectivity_manager_(std::make_unique()), fake_bluetooth_adapter_(std::make_unique()), fake_fast_initiation_manager_( std::make_unique()) {} Clock* FakeContext::GetClock() const { return fake_clock_.get(); } std::unique_ptr FakeContext::CreateTimer() { return std::make_unique(fake_clock_.get()); } ConnectivityManager* FakeContext::GetConnectivityManager() const { return fake_connectivity_manager_.get(); } sharing::api::BluetoothAdapter& FakeContext::GetBluetoothAdapter() const { return *fake_bluetooth_adapter_; } api::FastInitiationManager& FakeContext::GetFastInitiationManager() const { return *fake_fast_initiation_manager_; } std::unique_ptr FakeContext::CreateSequencedTaskRunner() const { auto task_runner = std::make_unique(fake_clock_.get(), 1); last_sequenced_task_runner_ = task_runner.get(); return task_runner; } std::unique_ptr FakeContext::CreateConcurrentTaskRunner( uint32_t concurrent_count) const { return std::make_unique(fake_clock_.get(), concurrent_count); } } // namespace nearby