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

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: Fix Clang 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
« no previous file with comments | « remoting/base/capabilities.cc ('k') | remoting/client/chromoting_client.h » ('j') | 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 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 <algorithm>
6 #include <vector>
7
8 #include "base/string_util.h"
9 #include "remoting/base/capabilities.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace {
13
14 struct HasCapabilityTestData {
15 const char* capabilities;
16 const char* key;
17 bool result;
18 };
19
20 struct IntersectTestData {
21 const char* left;
22 const char* right;
23 const char* result;
24 };
25
26 } // namespace
27
28 namespace remoting {
29
30 TEST(CapabilitiesTest, Empty) {
31 // Expect that nothing can be found in an empty set.
32 EXPECT_FALSE(HasCapability("", "a"));
33 EXPECT_FALSE(HasCapability(" ", "a"));
34 EXPECT_FALSE(HasCapability(" ", "a"));
35
36 // Expect that nothing can be found in an empty set, event when the key is
37 // empty.
38 EXPECT_FALSE(HasCapability("", ""));
39 EXPECT_FALSE(HasCapability(" ", ""));
40 EXPECT_FALSE(HasCapability(" ", ""));
41 }
42
43 TEST(CapabilitiesTest, HasCapability) {
44 HasCapabilityTestData data[] = {
45 { "", "", false },
46 { "a", "", false },
47 { "a", "a", true },
48 { "a a", "", false },
49 { "a a", "a", true },
50 { "a a", "z", false },
51 { "a b", "", false },
52 { "a b", "a", true },
53 { "a b", "b", true },
54 { "a b", "z", false },
55 { "a b c", "", false },
56 { "a b c", "a", true },
57 { "a b c", "b", true },
58 { "a b c", "z", false }
59 };
60
61 // Verify that HasCapability(|capabilities|, |key|) returns |result|.
62 // |result|.
63 for (size_t i = 0; i < arraysize(data); ++i) {
64 std::vector<std::string> caps;
65 Tokenize(data[i].capabilities, " ", &caps);
66
67 do {
68 EXPECT_EQ(HasCapability(JoinString(caps, " "), data[i].key),
69 data[i].result);
70 } while (std::next_permutation(caps.begin(), caps.end()));
71 }
72 }
73
74 TEST(CapabilitiesTest, Intersect) {
75 EXPECT_EQ(IntersectCapabilities("a", "a"), "a");
76
77 IntersectTestData data[] = {
78 { "", "", "" },
79 { "a", "", "" },
80 { "a", "a", "a" },
81 { "a", "b", "" },
82 { "a b", "", "" },
83 { "a b", "a", "a" },
84 { "a b", "b", "b" },
85 { "a b", "z", "" },
86 { "a b c", "a", "a" },
87 { "a b c", "b", "b" },
88 { "a b c", "a b", "a b" },
89 { "a b c", "b a", "a b" },
90 { "a b c", "z", "" }
91 };
92
93 // Verify that intersection of |right| with all permutations of |left| yields
94 // |result|.
95 for (size_t i = 0; i < arraysize(data); ++i) {
96 std::vector<std::string> caps;
97 Tokenize(data[i].left, " ", &caps);
98
99 do {
100 EXPECT_EQ(IntersectCapabilities(JoinString(caps, " "), data[i].right),
101 data[i].result);
102 } while (std::next_permutation(caps.begin(), caps.end()));
103 }
104 }
105
106 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/capabilities.cc ('k') | remoting/client/chromoting_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698