| 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 "remoting/host/chromeos/clipboard_aura.h" | 5 #include "remoting/host/chromeos/clipboard_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/test/test_timeouts.h" | 14 #include "base/test/test_timeouts.h" |
| 14 #include "remoting/base/constants.h" | 15 #include "remoting/base/constants.h" |
| 15 #include "remoting/proto/event.pb.h" | 16 #include "remoting/proto/event.pb.h" |
| 16 #include "remoting/protocol/clipboard_stub.h" | 17 #include "remoting/protocol/clipboard_stub.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "ui/base/clipboard/clipboard.h" | 20 #include "ui/base/clipboard/clipboard.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 50 public: | 51 public: |
| 51 ClipboardAuraTest() {} | 52 ClipboardAuraTest() {} |
| 52 void SetUp() override; | 53 void SetUp() override; |
| 53 void TearDown() override; | 54 void TearDown() override; |
| 54 | 55 |
| 55 protected: | 56 protected: |
| 56 void StopAndResetClipboard(); | 57 void StopAndResetClipboard(); |
| 57 | 58 |
| 58 base::MessageLoopForUI message_loop_; | 59 base::MessageLoopForUI message_loop_; |
| 59 ClientClipboard* client_clipboard_; | 60 ClientClipboard* client_clipboard_; |
| 60 scoped_ptr<ClipboardAura> clipboard_; | 61 std::unique_ptr<ClipboardAura> clipboard_; |
| 61 }; | 62 }; |
| 62 | 63 |
| 63 void ClipboardAuraTest::SetUp() { | 64 void ClipboardAuraTest::SetUp() { |
| 64 // Alert the clipboard class to which threads are allowed to access the | 65 // Alert the clipboard class to which threads are allowed to access the |
| 65 // clipboard. | 66 // clipboard. |
| 66 std::vector<base::PlatformThreadId> allowed_clipboard_threads; | 67 std::vector<base::PlatformThreadId> allowed_clipboard_threads; |
| 67 allowed_clipboard_threads.push_back(base::PlatformThread::CurrentId()); | 68 allowed_clipboard_threads.push_back(base::PlatformThread::CurrentId()); |
| 68 ui::Clipboard::SetAllowedThreads(allowed_clipboard_threads); | 69 ui::Clipboard::SetAllowedThreads(allowed_clipboard_threads); |
| 69 | 70 |
| 70 // Setup the clipboard. | 71 // Setup the clipboard. |
| 71 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 72 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 72 message_loop_.task_runner(); | 73 message_loop_.task_runner(); |
| 73 client_clipboard_ = new ClientClipboard(); | 74 client_clipboard_ = new ClientClipboard(); |
| 74 clipboard_.reset(new ClipboardAura()); | 75 clipboard_.reset(new ClipboardAura()); |
| 75 | 76 |
| 76 EXPECT_GT(TestTimeouts::tiny_timeout(), kTestOverridePollingInterval * 10) | 77 EXPECT_GT(TestTimeouts::tiny_timeout(), kTestOverridePollingInterval * 10) |
| 77 << "The test timeout should be greater than the polling interval"; | 78 << "The test timeout should be greater than the polling interval"; |
| 78 clipboard_->SetPollingIntervalForTesting(kTestOverridePollingInterval); | 79 clipboard_->SetPollingIntervalForTesting(kTestOverridePollingInterval); |
| 79 | 80 |
| 80 clipboard_->Start(make_scoped_ptr(client_clipboard_)); | 81 clipboard_->Start(base::WrapUnique(client_clipboard_)); |
| 81 } | 82 } |
| 82 | 83 |
| 83 void ClipboardAuraTest::TearDown() { | 84 void ClipboardAuraTest::TearDown() { |
| 84 ui::Clipboard::DestroyClipboardForCurrentThread(); | 85 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 85 } | 86 } |
| 86 | 87 |
| 87 void ClipboardAuraTest::StopAndResetClipboard() { | 88 void ClipboardAuraTest::StopAndResetClipboard() { |
| 88 clipboard_.reset(); | 89 clipboard_.reset(); |
| 89 } | 90 } |
| 90 | 91 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 FROM_HERE, base::Bind(&ClipboardAuraTest_MonitorClipboardChanges_Test:: | 124 FROM_HERE, base::Bind(&ClipboardAuraTest_MonitorClipboardChanges_Test:: |
| 124 StopAndResetClipboard, | 125 StopAndResetClipboard, |
| 125 base::Unretained(this)), | 126 base::Unretained(this)), |
| 126 TestTimeouts::tiny_timeout()); | 127 TestTimeouts::tiny_timeout()); |
| 127 message_loop_.PostDelayedTask(FROM_HERE, run_loop.QuitClosure(), | 128 message_loop_.PostDelayedTask(FROM_HERE, run_loop.QuitClosure(), |
| 128 TestTimeouts::tiny_timeout()); | 129 TestTimeouts::tiny_timeout()); |
| 129 run_loop.Run(); | 130 run_loop.Run(); |
| 130 } | 131 } |
| 131 | 132 |
| 132 } // namespace remoting | 133 } // namespace remoting |
| OLD | NEW |