OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/pairing_registry_delegate_win.h" | 5 #include "remoting/host/pairing_registry_delegate_win.h" |
6 | 6 |
7 #include <shlwapi.h> | 7 #include <shlwapi.h> |
8 | 8 |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "base/win/registry.h" | 12 #include "base/win/registry.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace remoting { | 15 namespace remoting { |
16 | 16 |
17 using protocol::PairingRegistry; | 17 using protocol::PairingRegistry; |
18 | 18 |
19 class PairingRegistryDelegateWinTest : public testing::Test { | 19 class PairingRegistryDelegateWinTest : public testing::Test { |
20 public: | 20 public: |
21 virtual void SetUp() OVERRIDE { | 21 virtual void SetUp() override { |
22 key_name_ = base::GenerateGUID(); | 22 key_name_ = base::GenerateGUID(); |
23 | 23 |
24 base::win::RegKey root; | 24 base::win::RegKey root; |
25 EXPECT_TRUE(root.Create(HKEY_CURRENT_USER, | 25 EXPECT_TRUE(root.Create(HKEY_CURRENT_USER, |
26 base::UTF8ToWide(key_name_).c_str(), | 26 base::UTF8ToWide(key_name_).c_str(), |
27 KEY_READ | KEY_WRITE) == ERROR_SUCCESS); | 27 KEY_READ | KEY_WRITE) == ERROR_SUCCESS); |
28 | 28 |
29 EXPECT_TRUE(privileged_.Create(root.Handle(), L"privileged", | 29 EXPECT_TRUE(privileged_.Create(root.Handle(), L"privileged", |
30 KEY_READ | KEY_WRITE) == ERROR_SUCCESS); | 30 KEY_READ | KEY_WRITE) == ERROR_SUCCESS); |
31 EXPECT_TRUE(unprivileged_.Create(root.Handle(), L"unprivileged", | 31 EXPECT_TRUE(unprivileged_.Create(root.Handle(), L"unprivileged", |
32 KEY_READ | KEY_WRITE) == ERROR_SUCCESS); | 32 KEY_READ | KEY_WRITE) == ERROR_SUCCESS); |
33 } | 33 } |
34 | 34 |
35 virtual void TearDown() OVERRIDE { | 35 virtual void TearDown() override { |
36 privileged_.Close(); | 36 privileged_.Close(); |
37 unprivileged_.Close(); | 37 unprivileged_.Close(); |
38 EXPECT_TRUE( | 38 EXPECT_TRUE( |
39 SHDeleteKey(HKEY_CURRENT_USER, | 39 SHDeleteKey(HKEY_CURRENT_USER, |
40 base::UTF8ToWide(key_name_).c_str()) == ERROR_SUCCESS); | 40 base::UTF8ToWide(key_name_).c_str()) == ERROR_SUCCESS); |
41 } | 41 } |
42 | 42 |
43 protected: | 43 protected: |
44 std::string key_name_; | 44 std::string key_name_; |
45 base::win::RegKey privileged_; | 45 base::win::RegKey privileged_; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 EXPECT_EQ(pairing.created_time(), unprivileged_pairing.created_time()); | 121 EXPECT_EQ(pairing.created_time(), unprivileged_pairing.created_time()); |
122 | 122 |
123 // Verify that the shared secret if not available. | 123 // Verify that the shared secret if not available. |
124 EXPECT_TRUE(unprivileged_pairing.shared_secret().empty()); | 124 EXPECT_TRUE(unprivileged_pairing.shared_secret().empty()); |
125 | 125 |
126 // Verify that a pairing cannot be saved. | 126 // Verify that a pairing cannot be saved. |
127 EXPECT_FALSE(delegate->Save(pairing)); | 127 EXPECT_FALSE(delegate->Save(pairing)); |
128 } | 128 } |
129 | 129 |
130 } // namespace remoting | 130 } // namespace remoting |
OLD | NEW |