Persist the original radio name, and restore it on app start if the radio name is our radio name.

PiperOrigin-RevId: 464148898
This commit is contained in:
jfcarroll
2022-07-29 13:43:35 -07:00
committed by Copybara-Service
parent 0d4964da7b
commit 778c77eacd
20 changed files with 22492 additions and 41 deletions
@@ -26,6 +26,68 @@ namespace nearby {
namespace windows {
namespace {
constexpr absl::string_view kName = "Test Radio Name";
constexpr absl::string_view kLongName =
"12345678901234567890123456789012345678";
constexpr absl::string_view kSpecialCharName = "~!@#$%^&*()_+<>:\"-}[{]";
TEST(BluetoothAdapter, DISABLED_SetNameSucceeds) {
BluetoothAdapter bluetooth_adapter;
auto original_name = bluetooth_adapter.GetName();
bluetooth_adapter.SetName(kName,
/* persist= */ false);
bluetooth_adapter.RestoreRadioNameIfNecessary();
EXPECT_EQ(bluetooth_adapter.GetName(), original_name);
}
TEST(BluetoothAdapter, DISABLED_SetNameWithTooManyChars) {
BluetoothAdapter bluetooth_adapter;
auto original_name = bluetooth_adapter.GetName();
bluetooth_adapter.SetName(kLongName,
/* persist= */ false);
auto result = bluetooth_adapter.GetName();
bluetooth_adapter.RestoreRadioNameIfNecessary();
EXPECT_EQ(result, kLongName);
EXPECT_EQ(bluetooth_adapter.GetName(), original_name);
}
TEST(BluetoothAdapter, DISABLED_SetNameWithSpecialCharsSucceeds) {
BluetoothAdapter bluetooth_adapter;
auto original_name = bluetooth_adapter.GetName();
bluetooth_adapter.SetName(kSpecialCharName,
/* persist= */ false);
auto result = bluetooth_adapter.GetName();
bluetooth_adapter.RestoreRadioNameIfNecessary();
EXPECT_EQ(result, kSpecialCharName);
EXPECT_EQ(bluetooth_adapter.GetName(), original_name);
}
TEST(BluetoothAdapter, DISABLED_SetNameWithEmptyStringSetsOriginalName) {
BluetoothAdapter bluetooth_adapter;
auto original_name = bluetooth_adapter.GetName();
bluetooth_adapter.SetName("",
/* persist= */ false);
EXPECT_EQ(bluetooth_adapter.GetName(), original_name);
}
TEST(BluetoothAdapter, DISABLED_SetNameWithNullPtrSetsOriginalName) {
BluetoothAdapter bluetooth_adapter;
auto original_name = bluetooth_adapter.GetName();
bluetooth_adapter.SetName(nullptr,
/* persist= */ false);
EXPECT_EQ(bluetooth_adapter.GetName(), original_name);
}
TEST(BluetoothAdapter, DISABLED_SetStatus) {
BluetoothAdapter bluetooth_adapter;
EXPECT_TRUE(