Index: chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc |
diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc b/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc |
index 32cf9ce402652fb198c2a8abe2a91f29d49f210c..d13dccb39efb4db2cc8515e547a0f3d50a0c48e2 100644 |
--- a/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc |
+++ b/chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc |
@@ -106,16 +106,15 @@ class NativeMessagingTest : public ::testing::Test, |
} |
virtual void TearDown() OVERRIDE { |
- if (native_message_process_host_.get()) { |
- BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, |
- native_message_process_host_.release()); |
+ if (native_message_host_.get()) { |
+ BrowserThread::DeleteSoon( |
+ BrowserThread::IO, FROM_HERE, native_message_host_.release()); |
} |
base::RunLoop().RunUntilIdle(); |
} |
- virtual void PostMessageFromNativeProcess( |
- int port_id, |
- const std::string& message) OVERRIDE { |
+ virtual void PostMessageFromNativeHost(int port_id, |
+ const std::string& message) OVERRIDE { |
last_message_ = message; |
// Parse the message. |
@@ -164,7 +163,7 @@ class NativeMessagingTest : public ::testing::Test, |
base::ScopedTempDir temp_dir_; |
// Force the channel to be dev. |
ScopedCurrentChannel current_channel_; |
- scoped_ptr<NativeMessageProcessHost> native_message_process_host_; |
+ scoped_ptr<NativeMessageHost> native_message_host_; |
scoped_ptr<base::RunLoop> run_loop_; |
content::TestBrowserThreadBundle thread_bundle_; |
std::string last_message_; |
@@ -180,15 +179,20 @@ TEST_F(NativeMessagingTest, SingleSendMessageRead) { |
scoped_ptr<NativeProcessLauncher> launcher = |
FakeLauncher::Create(temp_input_file, temp_output_file).Pass(); |
- native_message_process_host_ = NativeMessageProcessHost::CreateWithLauncher( |
- AsWeakPtr(), ScopedTestNativeMessagingHost::kExtensionId, "empty_app.py", |
- 0, launcher.Pass()); |
- ASSERT_TRUE(native_message_process_host_.get()); |
+ native_message_host_ = NativeMessageProcessHost::CreateWithLauncher( |
+ AsWeakPtr(), |
+ ScopedTestNativeMessagingHost::kExtensionId, |
+ "empty_app.py", |
+ 0, |
+ launcher.Pass()); |
+ ASSERT_TRUE(native_message_host_.get()); |
run_loop_.reset(new base::RunLoop()); |
run_loop_->RunUntilIdle(); |
if (last_message_.empty()) { |
run_loop_.reset(new base::RunLoop()); |
+ scoped_ptr<NativeMessageProcessHost> native_message_process_host_( |
+ static_cast<NativeMessageProcessHost*>(native_message_host_.release())); |
native_message_process_host_->ReadNowForTesting(); |
run_loop_->Run(); |
} |
@@ -226,13 +230,16 @@ TEST_F(NativeMessagingTest, SingleSendMessageWrite) { |
scoped_ptr<NativeProcessLauncher> launcher = |
FakeLauncher::CreateWithPipeInput(read_file.Pass(), |
temp_output_file).Pass(); |
- native_message_process_host_ = NativeMessageProcessHost::CreateWithLauncher( |
- AsWeakPtr(), ScopedTestNativeMessagingHost::kExtensionId, "empty_app.py", |
- 0, launcher.Pass()); |
- ASSERT_TRUE(native_message_process_host_.get()); |
+ native_message_host_ = NativeMessageProcessHost::CreateWithLauncher( |
+ AsWeakPtr(), |
+ ScopedTestNativeMessagingHost::kExtensionId, |
+ "empty_app.py", |
+ 0, |
+ launcher.Pass()); |
+ ASSERT_TRUE(native_message_host_.get()); |
base::RunLoop().RunUntilIdle(); |
- native_message_process_host_->Send(kTestMessage); |
+ native_message_host_->Send(kTestMessage); |
base::RunLoop().RunUntilIdle(); |
std::string output; |
@@ -253,12 +260,16 @@ TEST_F(NativeMessagingTest, EchoConnect) { |
ScopedTestNativeMessagingHost test_host; |
ASSERT_NO_FATAL_FAILURE(test_host.RegisterTestHost(false)); |
- native_message_process_host_ = NativeMessageProcessHost::Create( |
- NULL, AsWeakPtr(), ScopedTestNativeMessagingHost::kExtensionId, |
- ScopedTestNativeMessagingHost::kHostName, 0, false); |
- ASSERT_TRUE(native_message_process_host_.get()); |
+ native_message_host_ = NativeMessageProcessHost::Create( |
+ NULL, |
+ AsWeakPtr(), |
+ ScopedTestNativeMessagingHost::kExtensionId, |
+ ScopedTestNativeMessagingHost::kHostName, |
+ 0, |
+ false); |
+ ASSERT_TRUE(native_message_host_.get()); |
- native_message_process_host_->Send("{\"text\": \"Hello.\"}"); |
+ native_message_host_->Send("{\"text\": \"Hello.\"}"); |
run_loop_.reset(new base::RunLoop()); |
run_loop_->Run(); |
ASSERT_FALSE(last_message_.empty()); |
@@ -276,7 +287,7 @@ TEST_F(NativeMessagingTest, EchoConnect) { |
EXPECT_TRUE(last_message_parsed_->GetString("caller_url", &url)); |
EXPECT_EQ(expected_url, url); |
- native_message_process_host_->Send("{\"foo\": \"bar\"}"); |
+ native_message_host_->Send("{\"foo\": \"bar\"}"); |
run_loop_.reset(new base::RunLoop()); |
run_loop_->Run(); |
EXPECT_TRUE(last_message_parsed_->GetInteger("id", &id)); |
@@ -291,12 +302,16 @@ TEST_F(NativeMessagingTest, UserLevel) { |
ScopedTestNativeMessagingHost test_host; |
ASSERT_NO_FATAL_FAILURE(test_host.RegisterTestHost(true)); |
- native_message_process_host_ = NativeMessageProcessHost::Create( |
- NULL, AsWeakPtr(), ScopedTestNativeMessagingHost::kExtensionId, |
- ScopedTestNativeMessagingHost::kHostName, 0, true); |
- ASSERT_TRUE(native_message_process_host_.get()); |
+ native_message_host_ = NativeMessageProcessHost::Create( |
+ NULL, |
+ AsWeakPtr(), |
+ ScopedTestNativeMessagingHost::kExtensionId, |
+ ScopedTestNativeMessagingHost::kHostName, |
+ 0, |
+ true); |
+ ASSERT_TRUE(native_message_host_.get()); |
- native_message_process_host_->Send("{\"text\": \"Hello.\"}"); |
+ native_message_host_->Send("{\"text\": \"Hello.\"}"); |
run_loop_.reset(new base::RunLoop()); |
run_loop_->Run(); |
ASSERT_FALSE(last_message_.empty()); |
@@ -307,10 +322,14 @@ TEST_F(NativeMessagingTest, DisallowUserLevel) { |
ScopedTestNativeMessagingHost test_host; |
ASSERT_NO_FATAL_FAILURE(test_host.RegisterTestHost(true)); |
- native_message_process_host_ = NativeMessageProcessHost::Create( |
- NULL, AsWeakPtr(), ScopedTestNativeMessagingHost::kExtensionId, |
- ScopedTestNativeMessagingHost::kHostName, 0, false); |
- ASSERT_TRUE(native_message_process_host_.get()); |
+ native_message_host_ = NativeMessageProcessHost::Create( |
+ NULL, |
+ AsWeakPtr(), |
+ ScopedTestNativeMessagingHost::kExtensionId, |
+ ScopedTestNativeMessagingHost::kHostName, |
+ 0, |
+ false); |
+ ASSERT_TRUE(native_message_host_.get()); |
run_loop_.reset(new base::RunLoop()); |
run_loop_->Run(); |