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 "chrome/browser/extensions/api/messaging/native_messaging_test_util.h" | 5 #include "chrome/browser/extensions/api/messaging/native_messaging_test_util.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 70 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
71 ScopedTestNativeMessagingHost test_host; | 71 ScopedTestNativeMessagingHost test_host; |
72 | 72 |
73 base::FilePath test_user_data_dir; | 73 base::FilePath test_user_data_dir; |
74 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_user_data_dir)); | 74 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_user_data_dir)); |
75 test_user_data_dir = test_user_data_dir.AppendASCII("native_messaging") | 75 test_user_data_dir = test_user_data_dir.AppendASCII("native_messaging") |
76 .AppendASCII("native_hosts"); | 76 .AppendASCII("native_hosts"); |
77 | 77 |
78 #if defined(OS_WIN) | 78 #if defined(OS_WIN) |
79 HKEY root_key = user_level ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; | 79 HKEY root_key = user_level ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; |
80 registry_override_.OverrideRegistry(root_key); | 80 ASSERT_NO_FATAL_FAILURE(registry_override_.OverrideRegistry(root_key)); |
81 #else | 81 #else |
82 path_override_.reset(new base::ScopedPathOverride( | 82 path_override_.reset(new base::ScopedPathOverride( |
83 user_level ? chrome::DIR_USER_NATIVE_MESSAGING | 83 user_level ? chrome::DIR_USER_NATIVE_MESSAGING |
84 : chrome::DIR_NATIVE_MESSAGING, | 84 : chrome::DIR_NATIVE_MESSAGING, |
85 temp_dir_.GetPath())); | 85 temp_dir_.GetPath())); |
86 #endif | 86 #endif |
87 | 87 |
88 #if defined(OS_POSIX) | 88 #if defined(OS_POSIX) |
89 base::FilePath host_path = test_user_data_dir.AppendASCII("echo.py"); | 89 base::FilePath host_path = test_user_data_dir.AppendASCII("echo.py"); |
90 #else | 90 #else |
91 base::FilePath host_path = test_user_data_dir.AppendASCII("echo.bat"); | 91 base::FilePath host_path = test_user_data_dir.AppendASCII("echo.bat"); |
92 #endif | 92 #endif |
93 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest( | 93 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest( |
94 temp_dir_.GetPath(), kHostName, host_path, user_level)); | 94 temp_dir_.GetPath(), kHostName, host_path, user_level)); |
95 | 95 |
96 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest( | 96 ASSERT_NO_FATAL_FAILURE(WriteTestNativeHostManifest( |
97 temp_dir_.GetPath(), kBinaryMissingHostName, | 97 temp_dir_.GetPath(), kBinaryMissingHostName, |
98 test_user_data_dir.AppendASCII("missing_nm_binary.exe"), user_level)); | 98 test_user_data_dir.AppendASCII("missing_nm_binary.exe"), user_level)); |
99 } | 99 } |
100 | 100 |
101 ScopedTestNativeMessagingHost::~ScopedTestNativeMessagingHost() {} | 101 ScopedTestNativeMessagingHost::~ScopedTestNativeMessagingHost() {} |
102 | 102 |
103 } // namespace extensions | 103 } // namespace extensions |
OLD | NEW |