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

Unified Diff: remoting/host/host_traits_unittest.cc

Issue 2464293002: [Chromoting] GetHostAttributes with tests (Closed)
Patch Set: Created 4 years, 1 month 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
« remoting/host/host_traits.cc ('K') | « remoting/host/host_traits.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/host_traits_unittest.cc
diff --git a/remoting/host/host_traits_unittest.cc b/remoting/host/host_traits_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e39497b18789cf242b07a6b4b302d367c096aaa8
--- /dev/null
+++ b/remoting/host/host_traits_unittest.cc
@@ -0,0 +1,42 @@
+// Copyright 2016 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 "remoting/host/host_traits.h"
+
+#include <string>
+
+#include "base/bind.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace remoting {
+
+// Ensures there is no DCHECK failure or crash in Register() and Callbacks.
+TEST(HostTraitsTest, Sanity) {
+ host_traits().ToString();
+}
+
+TEST(HostTraitsTest, DynamicValuesShouldBeEvaluated) {
+ const char trait_key[] = "A-Fake-Trait-Key-In-Host-Traits-Unit-Test";
+ bool value = false;
+ int evaluated_times = 0;
+
+ host_traits().Register(trait_key,
+ base::Bind([](int* evaluated_times, bool* value) {
+ (*evaluated_times)++;
+ return *value;
+ }, &evaluated_times, &value));
+
+ std::string result = host_traits().ToString();
+ ASSERT_FALSE(HostTraits::ContainsTrait(result, trait_key));
+ ASSERT_EQ(evaluated_times, 1);
+
+ value = true;
+ result = host_traits().ToString();
+ ASSERT_TRUE(HostTraits::ContainsTrait(result, trait_key));
+ ASSERT_EQ(evaluated_times, 2);
+
+ host_traits().Erase(trait_key);
+}
+
+} // namespace remoting
« remoting/host/host_traits.cc ('K') | « remoting/host/host_traits.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698