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

Side by Side Diff: remoting/base/capabilities_unittest.cc

Issue 13932020: Set the initial resolution of an RDP session to the client screen resolution if it is available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback #2 Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 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 "base/values.h"
6 #include "remoting/base/capabilities.h"
7 #include "remoting/proto/control.pb.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace remoting {
11
12 namespace {
13
14 const char kCapsAbc[] = "a b c";
15 const char kCapsAz[] = "a z";
16 const char kCapsXyz[] = "x y z";
17
18 } // namespace
19
20 TEST(CapabilitiesTest, Empty) {
21 // Verify that the set is empty after creation.
22 Capabilities caps1;
23 EXPECT_EQ(caps1.Size(), 0u);
24
25 // Verify that an empty string produces an empty set.
26 Capabilities caps2("");
27 EXPECT_EQ(caps2.Size(), 0u);
28
29 // Verify that a string containing only spaces produces an empty set.
30 Capabilities caps3(" ");
31 EXPECT_EQ(caps3.Size(), 0u);
32
33 // Verify that an empty set can be converted to a protobuf and back.
34 EXPECT_TRUE(caps2.FromProtocolMessage(*caps1.ToProtocolMessage()));
35 EXPECT_EQ(caps2.Size(), 0u);
36
37 // Verify that an empty set can be converted to base::ListValue and back.
38 EXPECT_TRUE(caps2.FromListValue(*caps1.ToListValue()));
39 EXPECT_EQ(caps2.Size(), 0u);
40 }
41
42 TEST(CapabilitiesTest, NotEmpty) {
43 Capabilities caps1(kCapsAbc);
44
45 EXPECT_EQ(caps1.Size(), 3u);
46 EXPECT_TRUE(caps1.HasCapability("a"));
47 EXPECT_TRUE(caps1.HasCapability("b"));
48 EXPECT_TRUE(caps1.HasCapability("c"));
49
50 // Verify that the set can be converted to a protobuf and back.
51 Capabilities caps2;
52 EXPECT_TRUE(caps2.FromProtocolMessage(*caps1.ToProtocolMessage()));
53 EXPECT_EQ(caps2.Size(), 3u);
54 EXPECT_TRUE(caps2.HasCapability("a"));
55 EXPECT_TRUE(caps2.HasCapability("b"));
56 EXPECT_TRUE(caps2.HasCapability("c"));
57
58 // Verify that the set can be converted to base::ListValue and back.
59 EXPECT_TRUE(caps2.FromListValue(*caps1.ToListValue()));
60 EXPECT_EQ(caps2.Size(), 3u);
61 EXPECT_TRUE(caps2.HasCapability("a"));
62 EXPECT_TRUE(caps2.HasCapability("b"));
63 EXPECT_TRUE(caps2.HasCapability("c"));
64 }
65
66 TEST(CapabilitiesTest, Intersect) {
67 Capabilities caps_abc(kCapsAbc);
68 Capabilities caps_az(kCapsAz);
69 Capabilities caps_empty;
70 Capabilities caps_xyz(kCapsXyz);
71
72 // Test intersection.
73 Capabilities caps_a = caps_abc.Intersect(caps_az);
74 EXPECT_EQ(caps_a.Size(), 1u);
75 EXPECT_TRUE(caps_a.HasCapability("a"));
76
77 // Test intersection with an empty set.
78 EXPECT_EQ(caps_abc.Intersect(caps_empty).Size(), 0u);
79
80 // Test intersection with a non-intersecting set.
81 EXPECT_EQ(caps_abc.Intersect(caps_xyz).Size(), 0u);
82 }
83
84 TEST(CapabilitiesTest, BadListValue) {
85 base::ListValue value1;
86 value1.AppendString("a b");
87
88 Capabilities caps;
89 EXPECT_FALSE(caps.FromListValue(value1));
90
91 base::ListValue value2;
92 value2.AppendBoolean(false);
93 EXPECT_FALSE(caps.FromListValue(value2));
94 }
95
96 TEST(CapabilitiesTest, BadProtocolMessage) {
97 protocol::Capabilities message1;
98 *(message1.add_capability()) = "a b";
99
100 Capabilities caps;
101 EXPECT_FALSE(caps.FromProtocolMessage(message1));
102 }
103
104 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698