Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: chrome/browser/extensions/api/messaging/native_message_process_host_unittest_posix.cc

Issue 10952014: Speculatively disable POSIX NativeMessagingTests all together to fix random unit_tests hangs. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 Feature::ScopedCurrentChannel current_channel_; 106 Feature::ScopedCurrentChannel current_channel_;
107 NativeMessageProcessHost* native_message_process_host_; 107 NativeMessageProcessHost* native_message_process_host_;
108 FilePath user_data_dir_; 108 FilePath user_data_dir_;
109 MessageLoopForIO message_loop_; 109 MessageLoopForIO message_loop_;
110 scoped_ptr<content::TestBrowserThread> ui_thread_; 110 scoped_ptr<content::TestBrowserThread> ui_thread_;
111 scoped_ptr<content::TestBrowserThread> file_thread_; 111 scoped_ptr<content::TestBrowserThread> file_thread_;
112 std::string last_posted_message_; 112 std::string last_posted_message_;
113 }; 113 };
114 114
115 // Read a single message from a local file (single_message_response.msg). 115 // Read a single message from a local file (single_message_response.msg).
116 TEST_F(NativeMessagingTest, SingleSendMessageRead) { 116 TEST_F(NativeMessagingTest, DISABLED_SingleSendMessageRead) {
117 FilePath temp_file; 117 FilePath temp_file;
118 file_util::CreateTemporaryFile(&temp_file); 118 file_util::CreateTemporaryFile(&temp_file);
119 FakeLauncher launcher(GetTestDir().AppendASCII("single_message_response.msg"), 119 FakeLauncher launcher(GetTestDir().AppendASCII("single_message_response.msg"),
120 temp_file); 120 temp_file);
121 NativeMessageProcessHost::CreateWithLauncher( 121 NativeMessageProcessHost::CreateWithLauncher(
122 AsWeakPtr(), "empty_app.py", "{}", 0, 122 AsWeakPtr(), "empty_app.py", "{}", 0,
123 NativeMessageProcessHost::TYPE_SEND_MESSAGE_REQUEST, base::Bind( 123 NativeMessageProcessHost::TYPE_SEND_MESSAGE_REQUEST, base::Bind(
124 &NativeMessagingTest::AcquireProcess, AsWeakPtr()), 124 &NativeMessagingTest::AcquireProcess, AsWeakPtr()),
125 launcher); 125 launcher);
126 message_loop_.RunAllPending(); 126 message_loop_.RunAllPending();
127 ASSERT_TRUE(native_message_process_host_); 127 ASSERT_TRUE(native_message_process_host_);
128 native_message_process_host_->ReadNowForTesting(); 128 native_message_process_host_->ReadNowForTesting();
129 message_loop_.RunAllPending(); 129 message_loop_.RunAllPending();
130 EXPECT_EQ(last_posted_message_, "{\"text\": \"Hi There!.\"}"); 130 EXPECT_EQ(last_posted_message_, "{\"text\": \"Hi There!.\"}");
131 file_util::Delete(temp_file, false /* non-recursive */); 131 file_util::Delete(temp_file, false /* non-recursive */);
132 } 132 }
133 133
134 // Tests sending a single message. The message should get written to 134 // Tests sending a single message. The message should get written to
135 // |temp_file| and should match the contents of single_message_request.msg. 135 // |temp_file| and should match the contents of single_message_request.msg.
136 TEST_F(NativeMessagingTest, SingleSendMessageWrite) { 136 TEST_F(NativeMessagingTest, DISABLED_SingleSendMessageWrite) {
137 FilePath temp_file; 137 FilePath temp_file;
138 file_util::CreateTemporaryFile(&temp_file); 138 file_util::CreateTemporaryFile(&temp_file);
139 FakeLauncher launcher(GetTestDir().AppendASCII("single_message_response.msg"), 139 FakeLauncher launcher(GetTestDir().AppendASCII("single_message_response.msg"),
140 temp_file); 140 temp_file);
141 NativeMessageProcessHost::CreateWithLauncher( 141 NativeMessageProcessHost::CreateWithLauncher(
142 AsWeakPtr(), "empty_app.py", "{\"text\": \"Hello.\"}", 0, 142 AsWeakPtr(), "empty_app.py", "{\"text\": \"Hello.\"}", 0,
143 NativeMessageProcessHost::TYPE_SEND_MESSAGE_REQUEST, base::Bind( 143 NativeMessageProcessHost::TYPE_SEND_MESSAGE_REQUEST, base::Bind(
144 &NativeMessagingTest::AcquireProcess, AsWeakPtr()), 144 &NativeMessagingTest::AcquireProcess, AsWeakPtr()),
145 launcher); 145 launcher);
146 message_loop_.RunAllPending(); 146 message_loop_.RunAllPending();
147 ASSERT_TRUE(native_message_process_host_); 147 ASSERT_TRUE(native_message_process_host_);
148 148
149 EXPECT_TRUE(file_util::ContentsEqual( 149 EXPECT_TRUE(file_util::ContentsEqual(
150 temp_file, GetTestDir().AppendASCII("single_message_request.msg"))); 150 temp_file, GetTestDir().AppendASCII("single_message_request.msg")));
151 151
152 file_util::Delete(temp_file, false /* non-recursive */); 152 file_util::Delete(temp_file, false /* non-recursive */);
153 } 153 }
154 154
155 // Test send message with a real client. The client just echo's back the text 155 // Test send message with a real client. The client just echo's back the text
156 // it recieved. 156 // it recieved.
157 TEST_F(NativeMessagingTest, EchoConnect) { 157 TEST_F(NativeMessagingTest, DISABLED_EchoConnect) {
158 NativeMessageProcessHost::Create( 158 NativeMessageProcessHost::Create(
159 AsWeakPtr(), "echo.py", "{\"text\": \"Hello.\"}", 0, 159 AsWeakPtr(), "echo.py", "{\"text\": \"Hello.\"}", 0,
160 NativeMessageProcessHost::TYPE_CONNECT, base::Bind( 160 NativeMessageProcessHost::TYPE_CONNECT, base::Bind(
161 &NativeMessagingTest::AcquireProcess, AsWeakPtr())); 161 &NativeMessagingTest::AcquireProcess, AsWeakPtr()));
162 message_loop_.RunAllPending(); 162 message_loop_.RunAllPending();
163 ASSERT_TRUE(native_message_process_host_); 163 ASSERT_TRUE(native_message_process_host_);
164 164
165 native_message_process_host_->ReadNowForTesting(); 165 native_message_process_host_->ReadNowForTesting();
166 message_loop_.RunAllPending(); 166 message_loop_.RunAllPending();
167 EXPECT_EQ(last_posted_message_, 167 EXPECT_EQ(last_posted_message_,
168 "{\"id\": 1, \"echo\": {\"text\": \"Hello.\"}}"); 168 "{\"id\": 1, \"echo\": {\"text\": \"Hello.\"}}");
169 169
170 native_message_process_host_->Send("{\"foo\": \"bar\"}"); 170 native_message_process_host_->Send("{\"foo\": \"bar\"}");
171 message_loop_.RunAllPending(); 171 message_loop_.RunAllPending();
172 native_message_process_host_->ReadNowForTesting(); 172 native_message_process_host_->ReadNowForTesting();
173 message_loop_.RunAllPending(); 173 message_loop_.RunAllPending();
174 EXPECT_EQ(last_posted_message_, "{\"id\": 2, \"echo\": {\"foo\": \"bar\"}}"); 174 EXPECT_EQ(last_posted_message_, "{\"id\": 2, \"echo\": {\"foo\": \"bar\"}}");
175 } 175 }
176 176
177 } // namespace extensions 177 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698