OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "remoting/host/json_host_config.h" | 9 #include "remoting/host/json_host_config.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 namespace remoting { | 12 namespace remoting { |
13 | 13 |
14 namespace { | 14 namespace { |
15 const char* kTestConfig = | 15 const char* kTestConfig = |
16 "{\n" | 16 "{\n" |
17 " \"xmpp_login\" : \"test@gmail.com\",\n" | 17 " \"xmpp_login\" : \"test@gmail.com\",\n" |
18 " \"xmpp_auth_token\" : \"TEST_AUTH_TOKEN\",\n" | 18 " \"xmpp_auth_token\" : \"TEST_AUTH_TOKEN\",\n" |
19 " \"host_id\" : \"TEST_HOST_ID\",\n" | 19 " \"host_id\" : \"TEST_HOST_ID\",\n" |
20 " \"host_name\" : \"TEST_MACHINE_NAME\",\n" | 20 " \"host_name\" : \"TEST_MACHINE_NAME\",\n" |
21 " \"private_key\" : \"TEST_PRIVATE_KEY\"\n" | 21 " \"private_key\" : \"TEST_PRIVATE_KEY\"\n" |
22 "}\n"; | 22 "}\n"; |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 class JsonHostConfigTest : public testing::Test { | 25 class JsonHostConfigTest : public testing::Test { |
26 protected: | 26 protected: |
27 static void WriteTestFile(const base::FilePath& filename) { | 27 static void WriteTestFile(const base::FilePath& filename) { |
28 file_util::WriteFile(filename, kTestConfig, std::strlen(kTestConfig)); | 28 base::WriteFile(filename, kTestConfig, std::strlen(kTestConfig)); |
29 } | 29 } |
30 | 30 |
31 // The temporary directory used to contain the test operations. | 31 // The temporary directory used to contain the test operations. |
32 base::ScopedTempDir test_dir_; | 32 base::ScopedTempDir test_dir_; |
33 }; | 33 }; |
34 | 34 |
35 TEST_F(JsonHostConfigTest, InvalidFile) { | 35 TEST_F(JsonHostConfigTest, InvalidFile) { |
36 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); | 36 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); |
37 base::FilePath non_existent_file = | 37 base::FilePath non_existent_file = |
38 test_dir_.path().AppendASCII("non_existent.json"); | 38 test_dir_.path().AppendASCII("non_existent.json"); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 EXPECT_EQ(new_auth_token_value, value); | 85 EXPECT_EQ(new_auth_token_value, value); |
86 EXPECT_TRUE(reader.GetString(kHostIdConfigPath, &value)); | 86 EXPECT_TRUE(reader.GetString(kHostIdConfigPath, &value)); |
87 EXPECT_EQ("TEST_HOST_ID", value); | 87 EXPECT_EQ("TEST_HOST_ID", value); |
88 EXPECT_TRUE(reader.GetString(kHostNameConfigPath, &value)); | 88 EXPECT_TRUE(reader.GetString(kHostNameConfigPath, &value)); |
89 EXPECT_EQ("TEST_MACHINE_NAME", value); | 89 EXPECT_EQ("TEST_MACHINE_NAME", value); |
90 EXPECT_TRUE(reader.GetString(kPrivateKeyConfigPath, &value)); | 90 EXPECT_TRUE(reader.GetString(kPrivateKeyConfigPath, &value)); |
91 EXPECT_EQ("TEST_PRIVATE_KEY", value); | 91 EXPECT_EQ("TEST_PRIVATE_KEY", value); |
92 } | 92 } |
93 | 93 |
94 } | 94 } |
OLD | NEW |