Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Unified Diff: device/bluetooth/bluetooth_low_energy_win_unittest.cc

Issue 376313002: Add unit tests for DeviceRegistryPropertyValue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_low_energy_win_unittest.cc
diff --git a/device/bluetooth/bluetooth_low_energy_win_unittest.cc b/device/bluetooth/bluetooth_low_energy_win_unittest.cc
index 2db9d2081327f93100391f1a51fcdc4440bec037..94ff8cb88e74482489df3e505e61215eb072da1b 100644
--- a/device/bluetooth/bluetooth_low_energy_win_unittest.cc
+++ b/device/bluetooth/bluetooth_low_energy_win_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/strings/sys_string_conversions.h"
#include "device/bluetooth/bluetooth_low_energy_win.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -47,4 +48,27 @@ TEST_F(BluetoothLowEnergyWinTest, ExtractInvalidBluetoothAddress) {
EXPECT_FALSE(error.empty());
}
+TEST_F(BluetoothLowEnergyWinTest, DeviceRegistryPropertyValueAsString) {
+ std::string test_value = "String used for round trip test.";
+ std::wstring wide_value = base::SysUTF8ToWide(test_value);
+ size_t buffer_size = (wide_value.size() + 1) * sizeof(wchar_t);
+ scoped_ptr<uint8_t[]> buffer(new uint8_t[buffer_size]);
+ memcpy(buffer.get(), wide_value.c_str(), buffer_size);
+ scoped_ptr<device::win::DeviceRegistryPropertyValue> value =
+ device::win::DeviceRegistryPropertyValue::Create(
+ REG_SZ, buffer.Pass(), buffer_size).Pass();
+ EXPECT_EQ(test_value, value->AsString());
+}
+
+TEST_F(BluetoothLowEnergyWinTest, DeviceRegistryPropertyValueAsDWORD) {
+ DWORD test_value = 5u;
+ size_t buffer_size = sizeof(DWORD);
+ scoped_ptr<uint8_t[]> buffer(new uint8_t[buffer_size]);
+ memcpy(buffer.get(), &test_value, buffer_size);
+ scoped_ptr<device::win::DeviceRegistryPropertyValue> value =
+ device::win::DeviceRegistryPropertyValue::Create(
+ REG_DWORD, buffer.Pass(), buffer_size).Pass();
+ EXPECT_EQ(test_value, value->AsDWORD());
+}
+
} // namespace device
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698