#include "device/bluetooth/floss/floss_manager_client.h"
#include <utility>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/task_environment.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/mock_bus.h"
#include "dbus/mock_exported_object.h"
#include "dbus/mock_object_proxy.h"
#include "dbus/object_manager.h"
#include "dbus/object_path.h"
#include "device/bluetooth/floss/floss_dbus_client.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace floss {
namespace {
DoAll;
const std::vector<std::pair<int, bool>> kMockAdaptersAvailable = …;
void FakeExportMethod(
const std::string& interface_name,
const std::string& method_name,
const dbus::ExportedObject::MethodCallCallback& method_call_callback,
dbus::ExportedObject::OnExportedCallback on_exported_callback) { … }
class TestManagerObserver : public FlossManagerClient::Observer { … };
}
class FlossManagerClientTest : public testing::Test { … };
TEST_F(FlossManagerClientTest, QueriesAdapterPresenceOnInit) { … }
TEST_F(FlossManagerClientTest, VerifyAdapterPresent) { … }
TEST_F(FlossManagerClientTest, VerifyAdapterPresentEnabled) { … }
TEST_F(FlossManagerClientTest, VerifyAdapterEnabled) { … }
TEST_F(FlossManagerClientTest, HandleManagerPresence) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(FlossManagerClientTest, SetFlossEnabledRetries) {
base::RunLoop loop;
TestManagerObserver observer(client_.get());
floss_enabled_target_ = false;
client_->Init(bus_.get(), kManagerInterface, -1,
GetCurrVersion(), base::DoNothing());
EXPECT_EQ(method_called_[manager::kSetFlossEnabled], 1);
EXPECT_EQ(method_called_[manager::kGetFlossEnabled], 1);
method_called_.clear();
fail_setfloss_count_ = 1;
fail_getfloss_count_ = 1;
floss_enabled_target_ = true;
SetFlossEnabled(true, 3, 0, loop.QuitClosure());
loop.Run();
EXPECT_EQ(method_called_[manager::kSetFlossEnabled], 2);
EXPECT_EQ(method_called_[manager::kGetFlossEnabled], 2);
}
#endif
TEST_F(FlossManagerClientTest, GetFlossApiVersion) { … }
TEST_F(FlossManagerClientTest, NewFlossDaemonIsNotCompatible) { … }
}