summaryrefslogtreecommitdiff
path: root/remoting/ios/bridge/host_proxy_unittest.mm
blob: 9641e63d71656ec76a5852e97dc3b23a92859e69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif

#import "remoting/ios/bridge/host_proxy.h"

#import "base/compiler_specific.h"
#import "testing/gtest_mac.h"

namespace remoting {

class HostProxyTest : public ::testing::Test {
 protected:
  virtual void SetUp() OVERRIDE { hostProxy_ = [[HostProxy alloc] init]; }

  void CallPassThroughFunctions() {
    [hostProxy_ mouseAction:webrtc::DesktopVector(0, 0)
                 wheelDelta:webrtc::DesktopVector(0, 0)
                whichButton:0
                 buttonDown:NO];
    [hostProxy_ keyboardAction:0 keyDown:NO];
  }

  HostProxy* hostProxy_;
};

TEST_F(HostProxyTest, ConnectDisconnect) {
  CallPassThroughFunctions();

  ASSERT_FALSE([hostProxy_ isConnected]);
  [hostProxy_ connectToHost:@""
                  authToken:@""
                   jabberId:@""
                     hostId:@""
                  publicKey:@""
                   delegate:nil];
  ASSERT_TRUE([hostProxy_ isConnected]);

  CallPassThroughFunctions();

  [hostProxy_ disconnectFromHost];
  ASSERT_FALSE([hostProxy_ isConnected]);

  CallPassThroughFunctions();
}

}  // namespace remoting