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

Side by Side Diff: chromeos/dbus/privet_daemon_manager_client_unittest.cc

Issue 2291693002: Remove obsolete ChromeOS DBus bindings for privetd (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « chromeos/dbus/privet_daemon_manager_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chromeos/dbus/privet_daemon_manager_client.h"
6
7 #include <stddef.h>
8 #include <stdint.h>
9
10 #include <memory>
11
12 #include "base/strings/string_number_conversions.h"
13 #include "dbus/message.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace chromeos {
17
18 TEST(PrivetDaemonManagerClientTest, ReadPairingInfo) {
19 std::unique_ptr<dbus::Response> message(dbus::Response::CreateEmpty());
20 dbus::MessageWriter writer(message.get());
21 dbus::MessageWriter variant_writer(nullptr);
22 dbus::MessageWriter variant_array_writer(nullptr);
23 dbus::MessageWriter struct_entry_writer(nullptr);
24
25 writer.OpenVariant("a{sv}", &variant_writer);
26 variant_writer.OpenArray("{sv}", &variant_array_writer);
27
28 const uint8_t code_value[] = {0x67, 0x12, 0x23, 0x45, 0x64};
29 variant_array_writer.OpenDictEntry(&struct_entry_writer);
30 struct_entry_writer.AppendString("code");
31 dbus::MessageWriter struct_field_writer(nullptr);
32 struct_entry_writer.OpenVariant("ay", &struct_field_writer);
33 struct_field_writer.AppendArrayOfBytes(code_value, arraysize(code_value));
34 struct_entry_writer.CloseContainer(&struct_field_writer);
35 variant_array_writer.CloseContainer(&struct_entry_writer);
36
37 const char* string_items[] = {"mode", "sessionId"};
38 for (size_t i = 0; i < arraysize(string_items); ++i) {
39 variant_array_writer.OpenDictEntry(&struct_entry_writer);
40 struct_entry_writer.AppendString(string_items[i]);
41 struct_entry_writer.AppendVariantOfString(base::UintToString(i + 1));
42 variant_array_writer.CloseContainer(&struct_entry_writer);
43 }
44 writer.CloseContainer(&variant_writer);
45 variant_writer.CloseContainer(&variant_array_writer);
46
47 dbus::MessageReader reader(message.get());
48 PrivetDaemonManagerClient::PairingInfoProperty pairing_info;
49 EXPECT_TRUE(pairing_info.PopValueFromReader(&reader));
50
51 EXPECT_EQ(
52 std::vector<uint8_t>(code_value, code_value + arraysize(code_value)),
53 pairing_info.value().code());
54 EXPECT_EQ("1", pairing_info.value().mode());
55 EXPECT_EQ("2", pairing_info.value().session_id());
56 }
57
58 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/privet_daemon_manager_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698