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

Side by Side Diff: extensions/browser/api/cast_channel/cast_channel_apitest.cc

Issue 480173004: Fix flaky CastChannelAPI.TestOpenError test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/extensions/extension_function_test_utils.h" 9 #include "chrome/browser/extensions/extension_function_test_utils.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 #endif 262 #endif
263 // Test loading extension, execute a open-send-close sequence, then get logs. 263 // Test loading extension, execute a open-send-close sequence, then get logs.
264 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestGetLogs) { 264 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestGetLogs) {
265 SetUpOpenSendClose(); 265 SetUpOpenSendClose();
266 266
267 EXPECT_TRUE(RunExtensionSubtest("cast_channel/api", "test_get_logs.html")); 267 EXPECT_TRUE(RunExtensionSubtest("cast_channel/api", "test_get_logs.html"));
268 } 268 }
269 269
270 // TODO(munjal): Win Dbg has a workaround that makes RunExtensionSubtest 270 // TODO(munjal): Win Dbg has a workaround that makes RunExtensionSubtest
271 // always return true without actually running the test. Remove when fixed. 271 // always return true without actually running the test. Remove when fixed.
272 // Flaky on mac: crbug.com/393969 272 #if defined(OS_WIN) && !defined(NDEBUG)
273 #if (defined(OS_WIN) && !defined(NDEBUG)) || defined(OS_MACOSX)
274 #define MAYBE_TestOpenError DISABLED_TestOpenError 273 #define MAYBE_TestOpenError DISABLED_TestOpenError
275 #else 274 #else
276 #define MAYBE_TestOpenError TestOpenError 275 #define MAYBE_TestOpenError TestOpenError
277 #endif 276 #endif
278 // Test the case when socket open results in an error. 277 // Test the case when socket open results in an error.
279 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestOpenError) { 278 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestOpenError) {
280 SetUpMockCastSocket(); 279 SetUpMockCastSocket();
281 280
282 EXPECT_CALL(*mock_cast_socket_, Connect(_)) 281 EXPECT_CALL(*mock_cast_socket_, Connect(_))
283 .WillOnce(DoAll(InvokeDelegateOnError(this, GetApi()), 282 .WillOnce(DoAll(InvokeDelegateOnError(this, GetApi()),
284 InvokeCompletionCallback<0>(net::ERR_CONNECTION_FAILED))); 283 InvokeCompletionCallback<0>(net::ERR_CONNECTION_FAILED)));
285 EXPECT_CALL(*mock_cast_socket_, error_state()) 284 EXPECT_CALL(*mock_cast_socket_, error_state())
286 .WillRepeatedly(Return(cast_channel::CHANNEL_ERROR_CONNECT_ERROR)); 285 .WillRepeatedly(Return(cast_channel::CHANNEL_ERROR_CONNECT_ERROR));
287 EXPECT_CALL(*mock_cast_socket_, ready_state()) 286 EXPECT_CALL(*mock_cast_socket_, ready_state())
288 .WillRepeatedly(Return(cast_channel::READY_STATE_CLOSED)); 287 .WillRepeatedly(Return(cast_channel::READY_STATE_CLOSED));
289 EXPECT_CALL(*mock_cast_socket_, Close(_)) 288 EXPECT_CALL(*mock_cast_socket_, Close(_))
290 .WillOnce(InvokeCompletionCallback<0>(net::OK)); 289 .WillOnce(InvokeCompletionCallback<0>(net::OK));
291 290
292 EXPECT_TRUE(RunExtensionSubtest("cast_channel/api", 291 EXPECT_TRUE(RunExtensionSubtest("cast_channel/api",
293 "test_open_error.html")); 292 "test_open_error.html"));
294
295 ResultCatcher catcher;
296 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
297 } 293 }
298 294
299 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestOpenInvalidConnectInfo) { 295 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestOpenInvalidConnectInfo) {
300 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); 296 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension());
301 scoped_refptr<extensions::CastChannelOpenFunction> cast_channel_open_function; 297 scoped_refptr<extensions::CastChannelOpenFunction> cast_channel_open_function;
302 298
303 // Invalid URL 299 // Invalid URL
304 // TODO(mfoltz): Remove this test case when fixing crbug.com/331905 300 // TODO(mfoltz): Remove this test case when fixing crbug.com/331905
305 cast_channel_open_function = CreateOpenFunction(empty_extension); 301 cast_channel_open_function = CreateOpenFunction(empty_extension);
306 std::string error(utils::RunFunctionAndReturnError( 302 std::string error(utils::RunFunctionAndReturnError(
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 cast_channel_send_function.get(), 385 cast_channel_send_function.get(),
390 "[{\"channelId\": 1, \"url\": \"cast://127.0.0.1:8009\", " 386 "[{\"channelId\": 1, \"url\": \"cast://127.0.0.1:8009\", "
391 "\"connectInfo\": " 387 "\"connectInfo\": "
392 "{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, " 388 "{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, "
393 "\"auth\": \"ssl\"}, \"readyState\": \"open\"}, " 389 "\"auth\": \"ssl\"}, \"readyState\": \"open\"}, "
394 "{\"namespace_\": \"foo\", \"sourceId\": \"src\", " 390 "{\"namespace_\": \"foo\", \"sourceId\": \"src\", "
395 "\"destinationId\": \"\", \"data\": \"data\"}]", 391 "\"destinationId\": \"\", \"data\": \"data\"}]",
396 browser()); 392 browser());
397 EXPECT_EQ(error, "message_info.destination_id is required"); 393 EXPECT_EQ(error, "message_info.destination_id is required");
398 } 394 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698