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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/base/capabilities.cc ('k') | remoting/client/chromoting_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/capabilities_unittest.cc
diff --git a/remoting/base/capabilities_unittest.cc b/remoting/base/capabilities_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..16b9c0fa4bf4d1150e14eb620a3b46283e44160a
--- /dev/null
+++ b/remoting/base/capabilities_unittest.cc
@@ -0,0 +1,106 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <algorithm>
+#include <vector>
+
+#include "base/string_util.h"
+#include "remoting/base/capabilities.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+struct HasCapabilityTestData {
+ const char* capabilities;
+ const char* key;
+ bool result;
+};
+
+struct IntersectTestData {
+ const char* left;
+ const char* right;
+ const char* result;
+};
+
+} // namespace
+
+namespace remoting {
+
+TEST(CapabilitiesTest, Empty) {
+ // Expect that nothing can be found in an empty set.
+ EXPECT_FALSE(HasCapability("", "a"));
+ EXPECT_FALSE(HasCapability(" ", "a"));
+ EXPECT_FALSE(HasCapability(" ", "a"));
+
+ // Expect that nothing can be found in an empty set, event when the key is
+ // empty.
+ EXPECT_FALSE(HasCapability("", ""));
+ EXPECT_FALSE(HasCapability(" ", ""));
+ EXPECT_FALSE(HasCapability(" ", ""));
+}
+
+TEST(CapabilitiesTest, HasCapability) {
+ HasCapabilityTestData data[] = {
+ { "", "", false },
+ { "a", "", false },
+ { "a", "a", true },
+ { "a a", "", false },
+ { "a a", "a", true },
+ { "a a", "z", false },
+ { "a b", "", false },
+ { "a b", "a", true },
+ { "a b", "b", true },
+ { "a b", "z", false },
+ { "a b c", "", false },
+ { "a b c", "a", true },
+ { "a b c", "b", true },
+ { "a b c", "z", false }
+ };
+
+ // Verify that HasCapability(|capabilities|, |key|) returns |result|.
+ // |result|.
+ for (size_t i = 0; i < arraysize(data); ++i) {
+ std::vector<std::string> caps;
+ Tokenize(data[i].capabilities, " ", &caps);
+
+ do {
+ EXPECT_EQ(HasCapability(JoinString(caps, " "), data[i].key),
+ data[i].result);
+ } while (std::next_permutation(caps.begin(), caps.end()));
+ }
+}
+
+TEST(CapabilitiesTest, Intersect) {
+ EXPECT_EQ(IntersectCapabilities("a", "a"), "a");
+
+ IntersectTestData data[] = {
+ { "", "", "" },
+ { "a", "", "" },
+ { "a", "a", "a" },
+ { "a", "b", "" },
+ { "a b", "", "" },
+ { "a b", "a", "a" },
+ { "a b", "b", "b" },
+ { "a b", "z", "" },
+ { "a b c", "a", "a" },
+ { "a b c", "b", "b" },
+ { "a b c", "a b", "a b" },
+ { "a b c", "b a", "a b" },
+ { "a b c", "z", "" }
+ };
+
+ // Verify that intersection of |right| with all permutations of |left| yields
+ // |result|.
+ for (size_t i = 0; i < arraysize(data); ++i) {
+ std::vector<std::string> caps;
+ Tokenize(data[i].left, " ", &caps);
+
+ do {
+ EXPECT_EQ(IntersectCapabilities(JoinString(caps, " "), data[i].right),
+ data[i].result);
+ } while (std::next_permutation(caps.begin(), caps.end()));
+ }
+}
+
+} // namespace remoting
« 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