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

Side by Side Diff: remoting/protocol/fake_session.h

Issue 1531983002: Replace ice_connection_to_client_unittest.cc with connection_unittest.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « remoting/protocol/connection_unittest.cc ('k') | remoting/protocol/fake_session.cc » ('j') | 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 #ifndef REMOTING_PROTOCOL_FAKE_SESSION_H_ 5 #ifndef REMOTING_PROTOCOL_FAKE_SESSION_H_
6 #define REMOTING_PROTOCOL_FAKE_SESSION_H_ 6 #define REMOTING_PROTOCOL_FAKE_SESSION_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
13 #include "remoting/protocol/fake_stream_socket.h" 14 #include "remoting/protocol/fake_stream_socket.h"
14 #include "remoting/protocol/session.h" 15 #include "remoting/protocol/session.h"
15 #include "remoting/protocol/transport.h" 16 #include "remoting/protocol/transport.h"
16 17
17 namespace remoting { 18 namespace remoting {
18 namespace protocol { 19 namespace protocol {
19 20
20 extern const char kTestJid[]; 21 extern const char kTestJid[];
21 22
22 class FakeTransport : public Transport { 23 class FakeTransport : public Transport {
(...skipping 12 matching lines...) Expand all
35 FakeStreamChannelFactory channel_factory_; 36 FakeStreamChannelFactory channel_factory_;
36 }; 37 };
37 38
38 // FakeSession is a dummy protocol::Session that uses FakeStreamSocket for all 39 // FakeSession is a dummy protocol::Session that uses FakeStreamSocket for all
39 // channels. 40 // channels.
40 class FakeSession : public Session { 41 class FakeSession : public Session {
41 public: 42 public:
42 FakeSession(); 43 FakeSession();
43 ~FakeSession() override; 44 ~FakeSession() override;
44 45
46 void SimulateConnection(FakeSession* peer);
47
45 EventHandler* event_handler() { return event_handler_; } 48 EventHandler* event_handler() { return event_handler_; }
46
47 void set_error(ErrorCode error) { error_ = error; } 49 void set_error(ErrorCode error) { error_ = error; }
48
49 bool is_closed() const { return closed_; } 50 bool is_closed() const { return closed_; }
50 51
51 // Session interface. 52 // Session interface.
52 void SetEventHandler(EventHandler* event_handler) override; 53 void SetEventHandler(EventHandler* event_handler) override;
53 ErrorCode error() override; 54 ErrorCode error() override;
54 const std::string& jid() override; 55 const std::string& jid() override;
55 const SessionConfig& config() override; 56 const SessionConfig& config() override;
56 FakeTransport* GetTransport() override; 57 FakeTransport* GetTransport() override;
57 void Close(ErrorCode error) override; 58 void Close(ErrorCode error) override;
58 59
59 public: 60 private:
60 EventHandler* event_handler_; 61 EventHandler* event_handler_ = nullptr;
61 scoped_ptr<SessionConfig> config_; 62 scoped_ptr<SessionConfig> config_;
62 63
63 std::string jid_; 64 std::string jid_;
64 65
65 FakeTransport transport_; 66 FakeTransport transport_;
66 67
67 ErrorCode error_; 68 ErrorCode error_ = OK;
68 bool closed_; 69 bool closed_ = false;
70
71 base::WeakPtr<FakeSession> peer_;
72
73 base::WeakPtrFactory<FakeSession> weak_factory_;
69 74
70 DISALLOW_COPY_AND_ASSIGN(FakeSession); 75 DISALLOW_COPY_AND_ASSIGN(FakeSession);
71 }; 76 };
72 77
73 } // namespace protocol 78 } // namespace protocol
74 } // namespace remoting 79 } // namespace remoting
75 80
76 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_ 81 #endif // REMOTING_PROTOCOL_FAKE_SESSION_H_
OLDNEW
« no previous file with comments | « remoting/protocol/connection_unittest.cc ('k') | remoting/protocol/fake_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698