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

Side by Side Diff: remoting/host/host_attributes_unittest.cc

Issue 2464293002: [Chromoting] GetHostAttributes with tests (Closed)
Patch Set: Resolve review comments 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 "remoting/host/host_attributes.h"
6
7 #include <string>
8
9 #include "base/bind.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace remoting {
13
14 // Ensures there is no DCHECK failure or crash in Register() and Callbacks.
15 TEST(HostAttributesTest, Sanity) {
16 HostAttributes().ToString();
17 }
18
19 TEST(HostAttributesTest, DynamicValuesShouldBeEvaluated) {
20 const char key[] = "A-Fake-Trait-Key-In-Host-Traits-Unit-Test";
21 bool value = false;
22 int evaluated_times = 0;
23
24 HostAttributes host_attributes;
25 host_attributes.Register(
26 key, base::Bind(
27 [](int* evaluated_times, bool* value) {
28 (*evaluated_times)++;
29 return *value;
30 },
31 &evaluated_times, &value));
32
33 std::string result = host_attributes.ToString();
34 ASSERT_FALSE(HostAttributes::ContainsAttribute(result, key));
35 ASSERT_EQ(evaluated_times, 1);
36
37 value = true;
38 result = host_attributes.ToString();
39 ASSERT_TRUE(HostAttributes::ContainsAttribute(result, key));
40 ASSERT_EQ(evaluated_times, 2);
41 }
42
43 } // namespace remoting
OLDNEW
« remoting/host/host_attributes.h ('K') | « remoting/host/host_attributes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698