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

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

Issue 417403002: Remove weak pointers from CastSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update 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 unified diff | Download patch | Annotate | Revision Log
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"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "extensions/browser/api/cast_channel/cast_channel_api.h" 13 #include "extensions/browser/api/cast_channel/cast_channel_api.h"
14 #include "extensions/browser/api/cast_channel/cast_socket.h" 14 #include "extensions/browser/api/cast_channel/cast_socket.h"
15 #include "extensions/common/api/cast_channel.h" 15 #include "extensions/common/api/cast_channel.h"
16 #include "extensions/common/switches.h" 16 #include "extensions/common/switches.h"
17 #include "net/base/capturing_net_log.h" 17 #include "net/base/capturing_net_log.h"
18 #include "net/base/completion_callback.h" 18 #include "net/base/completion_callback.h"
19 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gmock_mutant.h" 21 #include "testing/gmock_mutant.h"
22 22
23 // TODO(mfoltz): Mock out the ApiResourceManager to resolve threading issues
24 // (crbug.com/398242) and simulate unloading of the extension.
25
23 namespace cast_channel = extensions::core_api::cast_channel; 26 namespace cast_channel = extensions::core_api::cast_channel;
24 using cast_channel::CastSocket; 27 using cast_channel::CastSocket;
25 using cast_channel::ChannelError; 28 using cast_channel::ChannelError;
26 using cast_channel::MessageInfo; 29 using cast_channel::MessageInfo;
27 using cast_channel::ReadyState; 30 using cast_channel::ReadyState;
28 using extensions::Extension; 31 using extensions::Extension;
29 32
30 namespace utils = extension_function_test_utils; 33 namespace utils = extension_function_test_utils;
31 34
32 using ::testing::_; 35 using ::testing::_;
(...skipping 29 matching lines...) Expand all
62 class MockCastSocket : public CastSocket { 65 class MockCastSocket : public CastSocket {
63 public: 66 public:
64 explicit MockCastSocket(CastSocket::Delegate* delegate, 67 explicit MockCastSocket(CastSocket::Delegate* delegate,
65 net::IPEndPoint ip_endpoint, 68 net::IPEndPoint ip_endpoint,
66 net::NetLog* net_log) 69 net::NetLog* net_log)
67 : CastSocket(kTestExtensionId, ip_endpoint, 70 : CastSocket(kTestExtensionId, ip_endpoint,
68 cast_channel::CHANNEL_AUTH_TYPE_SSL, delegate, net_log, 71 cast_channel::CHANNEL_AUTH_TYPE_SSL, delegate, net_log,
69 base::TimeDelta::FromMilliseconds(kTimeoutMs)) {} 72 base::TimeDelta::FromMilliseconds(kTimeoutMs)) {}
70 virtual ~MockCastSocket() {} 73 virtual ~MockCastSocket() {}
71 74
72 virtual bool CalledOnValidThread() const OVERRIDE {
73 // Always return true in testing.
74 return true;
75 }
76
77 MOCK_METHOD1(Connect, void(const net::CompletionCallback& callback)); 75 MOCK_METHOD1(Connect, void(const net::CompletionCallback& callback));
78 MOCK_METHOD2(SendMessage, void(const MessageInfo& message, 76 MOCK_METHOD2(SendMessage, void(const MessageInfo& message,
79 const net::CompletionCallback& callback)); 77 const net::CompletionCallback& callback));
80 MOCK_METHOD1(Close, void(const net::CompletionCallback& callback)); 78 MOCK_METHOD1(Close, void(const net::CompletionCallback& callback));
81 MOCK_CONST_METHOD0(ready_state, cast_channel::ReadyState()); 79 MOCK_CONST_METHOD0(ready_state, cast_channel::ReadyState());
82 MOCK_CONST_METHOD0(error_state, cast_channel::ChannelError()); 80 MOCK_CONST_METHOD0(error_state, cast_channel::ChannelError());
83 }; 81 };
84 82
85 } // namespace 83 } // namespace
86 84
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 cast_channel_send_function.get(), 373 cast_channel_send_function.get(),
376 "[{\"channelId\": 1, \"url\": \"cast://127.0.0.1:8009\", " 374 "[{\"channelId\": 1, \"url\": \"cast://127.0.0.1:8009\", "
377 "\"connectInfo\": " 375 "\"connectInfo\": "
378 "{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, " 376 "{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, "
379 "\"auth\": \"ssl\"}, \"readyState\": \"open\"}, " 377 "\"auth\": \"ssl\"}, \"readyState\": \"open\"}, "
380 "{\"namespace_\": \"foo\", \"sourceId\": \"src\", " 378 "{\"namespace_\": \"foo\", \"sourceId\": \"src\", "
381 "\"destinationId\": \"\", \"data\": \"data\"}]", 379 "\"destinationId\": \"\", \"data\": \"data\"}]",
382 browser()); 380 browser());
383 EXPECT_EQ(error, "message_info.destination_id is required"); 381 EXPECT_EQ(error, "message_info.destination_id is required");
384 } 382 }
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/cast_channel_api.cc ('k') | extensions/browser/api/cast_channel/cast_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698