OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_host_manifest
.h" | 5 #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest
.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/json/string_escape.h" | 10 #include "base/json/string_escape.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #else | 21 #else |
22 const char kTestHostPath[] = "/usr/bin/host"; | 22 const char kTestHostPath[] = "/usr/bin/host"; |
23 #endif | 23 #endif |
24 const char kTestOrigin[] = | 24 const char kTestOrigin[] = |
25 "chrome-extension://knldjmfmopnpolahpmmgbagdohdnhkik/"; | 25 "chrome-extension://knldjmfmopnpolahpmmgbagdohdnhkik/"; |
26 | 26 |
27 class NativeMessagingHostManifestTest : public ::testing::Test { | 27 class NativeMessagingHostManifestTest : public ::testing::Test { |
28 public: | 28 public: |
29 void SetUp() override { | 29 void SetUp() override { |
30 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 30 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
31 manifest_path_ = temp_dir_.path().AppendASCII("test.json"); | 31 manifest_path_ = temp_dir_.GetPath().AppendASCII("test.json"); |
32 } | 32 } |
33 | 33 |
34 protected: | 34 protected: |
35 bool WriteManifest(const std::string& name, | 35 bool WriteManifest(const std::string& name, |
36 const std::string& path, | 36 const std::string& path, |
37 const std::string& origin) { | 37 const std::string& origin) { |
38 return WriteManifest("{" | 38 return WriteManifest("{" |
39 " \"name\": \"" + name + "\"," | 39 " \"name\": \"" + name + "\"," |
40 " \"description\": \"Native Messaging Test\"," | 40 " \"description\": \"Native Messaging Test\"," |
41 " \"path\": " + base::GetQuotedJSONString(path) + "," | 41 " \"path\": " + base::GetQuotedJSONString(path) + "," |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 "chrome-extension://*/")); | 107 "chrome-extension://*/")); |
108 | 108 |
109 std::string error_message; | 109 std::string error_message; |
110 std::unique_ptr<NativeMessagingHostManifest> manifest = | 110 std::unique_ptr<NativeMessagingHostManifest> manifest = |
111 NativeMessagingHostManifest::Load(manifest_path_, &error_message); | 111 NativeMessagingHostManifest::Load(manifest_path_, &error_message); |
112 ASSERT_FALSE(manifest); | 112 ASSERT_FALSE(manifest); |
113 EXPECT_FALSE(error_message.empty()); | 113 EXPECT_FALSE(error_message.empty()); |
114 } | 114 } |
115 | 115 |
116 } // namespace extensions | 116 } // namespace extensions |
OLD | NEW |