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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 std::string(kTestNativeMessagingHostName) + ".json"); | 256 std::string(kTestNativeMessagingHostName) + ".json"); |
257 ASSERT_NO_FATAL_FAILURE(CreateTestNativeHostManifest(manifest_path)); | 257 ASSERT_NO_FATAL_FAILURE(CreateTestNativeHostManifest(manifest_path)); |
258 | 258 |
259 std::string hosts_option = base::StringPrintf( | 259 std::string hosts_option = base::StringPrintf( |
260 "%s=%s", extensions::kTestNativeMessagingHostName, | 260 "%s=%s", extensions::kTestNativeMessagingHostName, |
261 manifest_path.AsUTF8Unsafe().c_str()); | 261 manifest_path.AsUTF8Unsafe().c_str()); |
262 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 262 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
263 switches::kNativeMessagingHosts, hosts_option); | 263 switches::kNativeMessagingHosts, hosts_option); |
264 | 264 |
265 native_message_process_host_ = NativeMessageProcessHost::Create( | 265 native_message_process_host_ = NativeMessageProcessHost::Create( |
266 gfx::NativeView(), AsWeakPtr(), kTestNativeMessagingExtensionId, | 266 NULL, AsWeakPtr(), kTestNativeMessagingExtensionId, |
267 kTestNativeMessagingHostName, 0); | 267 kTestNativeMessagingHostName, 0); |
268 ASSERT_TRUE(native_message_process_host_.get()); | 268 ASSERT_TRUE(native_message_process_host_.get()); |
269 | 269 |
270 native_message_process_host_->Send("{\"text\": \"Hello.\"}"); | 270 native_message_process_host_->Send("{\"text\": \"Hello.\"}"); |
271 read_message_run_loop_.reset(new base::RunLoop()); | 271 read_message_run_loop_.reset(new base::RunLoop()); |
272 read_message_run_loop_->Run(); | 272 read_message_run_loop_->Run(); |
273 ASSERT_FALSE(last_message_.empty()); | 273 ASSERT_FALSE(last_message_.empty()); |
274 ASSERT_TRUE(last_message_parsed_); | 274 ASSERT_TRUE(last_message_parsed_); |
275 | 275 |
276 std::string expected_url = std::string("chrome-extension://") + | 276 std::string expected_url = std::string("chrome-extension://") + |
(...skipping 14 matching lines...) Expand all Loading... |
291 read_message_run_loop_->Run(); | 291 read_message_run_loop_->Run(); |
292 EXPECT_TRUE(last_message_parsed_->GetInteger("id", &id)); | 292 EXPECT_TRUE(last_message_parsed_->GetInteger("id", &id)); |
293 EXPECT_EQ(2, id); | 293 EXPECT_EQ(2, id); |
294 EXPECT_TRUE(last_message_parsed_->GetString("echo.foo", &text)); | 294 EXPECT_TRUE(last_message_parsed_->GetString("echo.foo", &text)); |
295 EXPECT_EQ("bar", text); | 295 EXPECT_EQ("bar", text); |
296 EXPECT_TRUE(last_message_parsed_->GetString("caller_url", &url)); | 296 EXPECT_TRUE(last_message_parsed_->GetString("caller_url", &url)); |
297 EXPECT_EQ(expected_url, url); | 297 EXPECT_EQ(expected_url, url); |
298 } | 298 } |
299 | 299 |
300 } // namespace extensions | 300 } // namespace extensions |
OLD | NEW |