OLD | NEW |
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 "ui/base/x/selection_requestor.h" | 5 #include "ui/base/x/selection_requestor.h" |
6 | 6 |
7 #include "base/memory/ref_counted_memory.h" | 7 #include "base/memory/ref_counted_memory.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 xev.xselection.requestor = x_window_; | 58 xev.xselection.requestor = x_window_; |
59 xev.xselection.selection = selection; | 59 xev.xselection.selection = selection; |
60 xev.xselection.target = target; | 60 xev.xselection.target = target; |
61 xev.xselection.property = requestor_->x_property_; | 61 xev.xselection.property = requestor_->x_property_; |
62 xev.xselection.time = CurrentTime; | 62 xev.xselection.time = CurrentTime; |
63 xev.xselection.type = SelectionNotify; | 63 xev.xselection.type = SelectionNotify; |
64 requestor_->OnSelectionNotify(xev); | 64 requestor_->OnSelectionNotify(xev); |
65 } | 65 } |
66 | 66 |
67 protected: | 67 protected: |
68 virtual void SetUp() OVERRIDE { | 68 virtual void SetUp() override { |
69 // Make X11 synchronous for our display connection. | 69 // Make X11 synchronous for our display connection. |
70 XSynchronize(x_display_, True); | 70 XSynchronize(x_display_, True); |
71 | 71 |
72 // Create a window for the selection requestor to use. | 72 // Create a window for the selection requestor to use. |
73 x_window_ = XCreateWindow(x_display_, | 73 x_window_ = XCreateWindow(x_display_, |
74 DefaultRootWindow(x_display_), | 74 DefaultRootWindow(x_display_), |
75 0, 0, 10, 10, // x, y, width, height | 75 0, 0, 10, 10, // x, y, width, height |
76 0, // border width | 76 0, // border width |
77 CopyFromParent, // depth | 77 CopyFromParent, // depth |
78 InputOnly, | 78 InputOnly, |
79 CopyFromParent, // visual | 79 CopyFromParent, // visual |
80 0, | 80 0, |
81 NULL); | 81 NULL); |
82 | 82 |
83 event_source_ = ui::PlatformEventSource::CreateDefault(); | 83 event_source_ = ui::PlatformEventSource::CreateDefault(); |
84 CHECK(ui::PlatformEventSource::GetInstance()); | 84 CHECK(ui::PlatformEventSource::GetInstance()); |
85 requestor_.reset(new SelectionRequestor(x_display_, x_window_, NULL)); | 85 requestor_.reset(new SelectionRequestor(x_display_, x_window_, NULL)); |
86 } | 86 } |
87 | 87 |
88 virtual void TearDown() OVERRIDE { | 88 virtual void TearDown() override { |
89 requestor_.reset(); | 89 requestor_.reset(); |
90 event_source_.reset(); | 90 event_source_.reset(); |
91 XDestroyWindow(x_display_, x_window_); | 91 XDestroyWindow(x_display_, x_window_); |
92 XSynchronize(x_display_, False); | 92 XSynchronize(x_display_, False); |
93 } | 93 } |
94 | 94 |
95 Display* x_display_; | 95 Display* x_display_; |
96 | 96 |
97 // |requestor_|'s window. | 97 // |requestor_|'s window. |
98 XID x_window_; | 98 XID x_window_; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 base::Bind(&SelectionRequestorTest::SendSelectionNotify, | 156 base::Bind(&SelectionRequestorTest::SendSelectionNotify, |
157 base::Unretained(this), | 157 base::Unretained(this), |
158 selection, | 158 selection, |
159 target2, | 159 target2, |
160 "Data2")); | 160 "Data2")); |
161 PerformBlockingConvertSelection( | 161 PerformBlockingConvertSelection( |
162 requestor_.get(), &atom_cache_, selection, target1, "Data1"); | 162 requestor_.get(), &atom_cache_, selection, target1, "Data1"); |
163 } | 163 } |
164 | 164 |
165 } // namespace ui | 165 } // namespace ui |
OLD | NEW |