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

Unified Diff: extensions/browser/api/cast_channel/cast_channel_apitest.cc

Issue 456213002: Cast channel: Add cast.channel.getLogs extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/cast_channel/cast_channel_apitest.cc
diff --git a/extensions/browser/api/cast_channel/cast_channel_apitest.cc b/extensions/browser/api/cast_channel/cast_channel_apitest.cc
index 69e2d8f8a95efcd540ac7b2ac1c2aa62513c189e..8f98ea229077c2a8fdf3ab2c87aca9b3a9002860 100644
--- a/extensions/browser/api/cast_channel/cast_channel_apitest.cc
+++ b/extensions/browser/api/cast_channel/cast_channel_apitest.cc
@@ -116,6 +116,25 @@ class CastChannelAPITest : public ExtensionApiTest {
.WillRepeatedly(Return(cast_channel::CHANNEL_ERROR_NONE));
}
+ void SetUpOpenSendClose() {
+ SetUpMockCastSocket();
+ {
+ InSequence sequence;
+ EXPECT_CALL(*mock_cast_socket_, Connect(_))
+ .WillOnce(InvokeCompletionCallback<0>(net::OK));
+ EXPECT_CALL(*mock_cast_socket_, ready_state())
+ .WillOnce(Return(cast_channel::READY_STATE_OPEN));
+ EXPECT_CALL(*mock_cast_socket_, SendMessage(A<const MessageInfo&>(), _))
+ .WillOnce(InvokeCompletionCallback<1>(net::OK));
+ EXPECT_CALL(*mock_cast_socket_, ready_state())
+ .WillOnce(Return(cast_channel::READY_STATE_OPEN));
+ EXPECT_CALL(*mock_cast_socket_, Close(_))
+ .WillOnce(InvokeCompletionCallback<0>(net::OK));
+ EXPECT_CALL(*mock_cast_socket_, ready_state())
+ .WillOnce(Return(cast_channel::READY_STATE_CLOSED));
+ }
+ }
+
extensions::CastChannelAPI* GetApi() {
return extensions::CastChannelAPI::Get(profile());
}
@@ -172,23 +191,7 @@ class CastChannelAPITest : public ExtensionApiTest {
// Test loading extension, opening a channel with ConnectInfo, adding a
// listener, writing, reading, and closing.
IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestOpenSendClose) {
- SetUpMockCastSocket();
-
- {
- InSequence dummy;
- EXPECT_CALL(*mock_cast_socket_, Connect(_))
- .WillOnce(InvokeCompletionCallback<0>(net::OK));
- EXPECT_CALL(*mock_cast_socket_, ready_state())
- .WillOnce(Return(cast_channel::READY_STATE_OPEN));
- EXPECT_CALL(*mock_cast_socket_, SendMessage(A<const MessageInfo&>(), _))
- .WillOnce(InvokeCompletionCallback<1>(net::OK));
- EXPECT_CALL(*mock_cast_socket_, ready_state())
- .WillOnce(Return(cast_channel::READY_STATE_OPEN));
- EXPECT_CALL(*mock_cast_socket_, Close(_))
- .WillOnce(InvokeCompletionCallback<0>(net::OK));
- EXPECT_CALL(*mock_cast_socket_, ready_state())
- .WillOnce(Return(cast_channel::READY_STATE_CLOSED));
- }
+ SetUpOpenSendClose();
EXPECT_TRUE(RunExtensionSubtest("cast_channel/api",
"test_open_send_close.html"));
@@ -204,23 +207,7 @@ IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestOpenSendClose) {
// Test loading extension, opening a channel with a URL, adding a listener,
// writing, reading, and closing.
IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestOpenSendCloseWithUrl) {
- SetUpMockCastSocket();
-
- {
- InSequence dummy;
- EXPECT_CALL(*mock_cast_socket_, Connect(_))
- .WillOnce(InvokeCompletionCallback<0>(net::OK));
- EXPECT_CALL(*mock_cast_socket_, ready_state())
- .WillOnce(Return(cast_channel::READY_STATE_OPEN));
- EXPECT_CALL(*mock_cast_socket_, SendMessage(A<const MessageInfo&>(), _))
- .WillOnce(InvokeCompletionCallback<1>(net::OK));
- EXPECT_CALL(*mock_cast_socket_, ready_state())
- .WillOnce(Return(cast_channel::READY_STATE_OPEN));
- EXPECT_CALL(*mock_cast_socket_, Close(_))
- .WillOnce(InvokeCompletionCallback<0>(net::OK));
- EXPECT_CALL(*mock_cast_socket_, ready_state())
- .WillOnce(Return(cast_channel::READY_STATE_CLOSED));
- }
+ SetUpOpenSendClose();
EXPECT_TRUE(RunExtensionSubtest("cast_channel/api",
"test_open_send_close_url.html"));
@@ -239,7 +226,7 @@ IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestOpenReceiveClose) {
SetUpMockCastSocket();
{
- InSequence dummy;
+ InSequence sequence;
EXPECT_CALL(*mock_cast_socket_, Connect(_))
.WillOnce(InvokeCompletionCallback<0>(net::OK));
EXPECT_CALL(*mock_cast_socket_, ready_state())
@@ -260,6 +247,20 @@ IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestOpenReceiveClose) {
EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
}
+// TODO(imcheng): Win Dbg has a workaround that makes RunExtensionSubtest
+// always return true without actually running the test. Remove when fixed.
+#if defined(OS_WIN) && !defined(NDEBUG)
+#define MAYBE_TestGetLogs DISABLED_TestGetLogs
+#else
+#define MAYBE_TestGetLogs TestGetLogs
+#endif
+// Test loading extension, execute a open-send-close sequence, then get logs.
+IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestGetLogs) {
+ SetUpOpenSendClose();
+
+ EXPECT_TRUE(RunExtensionSubtest("cast_channel/api", "test_get_logs.html"));
+}
+
// TODO(munjal): Win Dbg has a workaround that makes RunExtensionSubtest
// always return true without actually running the test. Remove when fixed.
// Flaky on mac: crbug.com/393969

Powered by Google App Engine
This is Rietveld 408576698