| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted_memory.h" | 11 #include "base/memory/ref_counted_memory.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/single_thread_task_runner.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/base/x/selection_utils.h" | 15 #include "ui/base/x/selection_utils.h" |
| 15 #include "ui/base/x/x11_util.h" | 16 #include "ui/base/x/x11_util.h" |
| 16 #include "ui/events/platform/platform_event_source.h" | 17 #include "ui/events/platform/platform_event_source.h" |
| 17 #include "ui/gfx/x/x11_atom_cache.h" | 18 #include "ui/gfx/x/x11_atom_cache.h" |
| 18 #include "ui/gfx/x/x11_types.h" | 19 #include "ui/gfx/x/x11_types.h" |
| 19 | 20 |
| 20 #include <X11/Xlib.h> | 21 #include <X11/Xlib.h> |
| 21 | 22 |
| 22 namespace ui { | 23 namespace ui { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 TEST_F(SelectionRequestorTest, NestedRequests) { | 135 TEST_F(SelectionRequestorTest, NestedRequests) { |
| 135 // Assume that |selection| will have no owner. If there is an owner, the owner | 136 // Assume that |selection| will have no owner. If there is an owner, the owner |
| 136 // will set the property passed into the XConvertSelection() request which is | 137 // will set the property passed into the XConvertSelection() request which is |
| 137 // undesirable. | 138 // undesirable. |
| 138 XAtom selection = atom_cache_.GetAtom("FAKE_SELECTION"); | 139 XAtom selection = atom_cache_.GetAtom("FAKE_SELECTION"); |
| 139 | 140 |
| 140 XAtom target1 = atom_cache_.GetAtom("TARGET1"); | 141 XAtom target1 = atom_cache_.GetAtom("TARGET1"); |
| 141 XAtom target2 = atom_cache_.GetAtom("TARGET2"); | 142 XAtom target2 = atom_cache_.GetAtom("TARGET2"); |
| 142 | 143 |
| 143 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); | 144 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
| 144 loop->PostTask(FROM_HERE, | 145 loop->task_runner()->PostTask( |
| 145 base::Bind(&PerformBlockingConvertSelection, | 146 FROM_HERE, |
| 146 base::Unretained(requestor_.get()), | 147 base::Bind(&PerformBlockingConvertSelection, |
| 147 base::Unretained(&atom_cache_), | 148 base::Unretained(requestor_.get()), |
| 148 selection, | 149 base::Unretained(&atom_cache_), selection, target2, "Data2")); |
| 149 target2, | 150 loop->task_runner()->PostTask( |
| 150 "Data2")); | 151 FROM_HERE, |
| 151 loop->PostTask(FROM_HERE, | 152 base::Bind(&SelectionRequestorTest::SendSelectionNotify, |
| 152 base::Bind(&SelectionRequestorTest::SendSelectionNotify, | 153 base::Unretained(this), selection, target1, "Data1")); |
| 153 base::Unretained(this), | 154 loop->task_runner()->PostTask( |
| 154 selection, | 155 FROM_HERE, |
| 155 target1, | 156 base::Bind(&SelectionRequestorTest::SendSelectionNotify, |
| 156 "Data1")); | 157 base::Unretained(this), selection, target2, "Data2")); |
| 157 loop->PostTask(FROM_HERE, | |
| 158 base::Bind(&SelectionRequestorTest::SendSelectionNotify, | |
| 159 base::Unretained(this), | |
| 160 selection, | |
| 161 target2, | |
| 162 "Data2")); | |
| 163 PerformBlockingConvertSelection( | 158 PerformBlockingConvertSelection( |
| 164 requestor_.get(), &atom_cache_, selection, target1, "Data1"); | 159 requestor_.get(), &atom_cache_, selection, target1, "Data1"); |
| 165 } | 160 } |
| 166 | 161 |
| 167 } // namespace ui | 162 } // namespace ui |
| OLD | NEW |