| OLD | NEW |
| 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 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 // X11 headers must be #included after gtest.h, since the X11 headers define | 12 // X11 headers must be #included after gtest.h, since the X11 headers define |
| 13 // some macros that cause errors in gtest-type-util.h. | 13 // some macros that cause errors in gtest-type-util.h. |
| 14 #include <X11/Xlib.h> | 14 #include <X11/Xlib.h> |
| 15 #include "remoting/host/linux/x_server_clipboard.h" | 15 #include "remoting/host/linux/x_server_clipboard.h" |
| 16 | 16 |
| 17 namespace remoting { | 17 namespace remoting { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class ClipboardTestClient { | 21 class ClipboardTestClient { |
| 22 public: | 22 public: |
| 23 ClipboardTestClient() : display_(NULL) {} | 23 ClipboardTestClient() : display_(nullptr) {} |
| 24 ~ClipboardTestClient() {} | 24 ~ClipboardTestClient() {} |
| 25 | 25 |
| 26 void Init(Display* display) { | 26 void Init(Display* display) { |
| 27 display_ = display; | 27 display_ = display; |
| 28 clipboard_.Init(display, | 28 clipboard_.Init(display, |
| 29 base::Bind(&ClipboardTestClient::OnClipboardChanged, | 29 base::Bind(&ClipboardTestClient::OnClipboardChanged, |
| 30 base::Unretained(this))); | 30 base::Unretained(this))); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void SetClipboardData(const std::string& clipboard_data) { | 33 void SetClipboardData(const std::string& clipboard_data) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 64 DISALLOW_COPY_AND_ASSIGN(ClipboardTestClient); | 64 DISALLOW_COPY_AND_ASSIGN(ClipboardTestClient); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace | 67 } // namespace |
| 68 | 68 |
| 69 class XServerClipboardTest : public testing::Test { | 69 class XServerClipboardTest : public testing::Test { |
| 70 public: | 70 public: |
| 71 void SetUp() override { | 71 void SetUp() override { |
| 72 // XSynchronize() ensures that PumpXEvents() fully processes all X server | 72 // XSynchronize() ensures that PumpXEvents() fully processes all X server |
| 73 // requests and responses before returning to the caller. | 73 // requests and responses before returning to the caller. |
| 74 Display* display1 = XOpenDisplay(NULL); | 74 Display* display1 = XOpenDisplay(nullptr); |
| 75 XSynchronize(display1, True); | 75 XSynchronize(display1, True); |
| 76 client1_.Init(display1); | 76 client1_.Init(display1); |
| 77 Display* display2 = XOpenDisplay(NULL); | 77 Display* display2 = XOpenDisplay(nullptr); |
| 78 XSynchronize(display2, True); | 78 XSynchronize(display2, True); |
| 79 client2_.Init(display2); | 79 client2_.Init(display2); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void TearDown() override { | 82 void TearDown() override { |
| 83 XCloseDisplay(client1_.display()); | 83 XCloseDisplay(client1_.display()); |
| 84 XCloseDisplay(client2_.display()); | 84 XCloseDisplay(client2_.display()); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void PumpXEvents() { | 87 void PumpXEvents() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 112 client2_.SetClipboardData("Text3"); | 112 client2_.SetClipboardData("Text3"); |
| 113 PumpXEvents(); | 113 PumpXEvents(); |
| 114 EXPECT_EQ("Text3", client1_.clipboard_data()); | 114 EXPECT_EQ("Text3", client1_.clipboard_data()); |
| 115 | 115 |
| 116 client2_.SetClipboardData("Text4"); | 116 client2_.SetClipboardData("Text4"); |
| 117 PumpXEvents(); | 117 PumpXEvents(); |
| 118 EXPECT_EQ("Text4", client1_.clipboard_data()); | 118 EXPECT_EQ("Text4", client1_.clipboard_data()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace remoting | 121 } // namespace remoting |
| OLD | NEW |