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

Side by Side 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 unified diff | Download patch
« remoting/host/host_traits.cc ('K') | « remoting/host/host_traits.cc ('k') | no next file » | 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 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_traits.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(HostTraitsTest, Sanity) {
16 host_traits().ToString();
17 }
18
19 TEST(HostTraitsTest, DynamicValuesShouldBeEvaluated) {
20 const char trait_key[] = "A-Fake-Trait-Key-In-Host-Traits-Unit-Test";
21 bool value = false;
22 int evaluated_times = 0;
23
24 host_traits().Register(trait_key,
25 base::Bind([](int* evaluated_times, bool* value) {
26 (*evaluated_times)++;
27 return *value;
28 }, &evaluated_times, &value));
29
30 std::string result = host_traits().ToString();
31 ASSERT_FALSE(HostTraits::ContainsTrait(result, trait_key));
32 ASSERT_EQ(evaluated_times, 1);
33
34 value = true;
35 result = host_traits().ToString();
36 ASSERT_TRUE(HostTraits::ContainsTrait(result, trait_key));
37 ASSERT_EQ(evaluated_times, 2);
38
39 host_traits().Erase(trait_key);
40 }
41
42 } // namespace remoting
OLDNEW
« 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