Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1449)

Unified Diff: remoting/host/chromeos/clipboard_aura_unittest.cc

Issue 718313002: Revert "Remote assistance on Chrome OS Part VIII - Compile on Ozone" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/chromeos/clipboard_aura.cc ('k') | remoting/host/chromeos/mouse_cursor_monitor_aura.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/chromeos/clipboard_aura_unittest.cc
diff --git a/remoting/host/chromeos/clipboard_aura_unittest.cc b/remoting/host/chromeos/clipboard_aura_unittest.cc
deleted file mode 100644
index 5201c11ee4276565168bb07f82572156fda95bf7..0000000000000000000000000000000000000000
--- a/remoting/host/chromeos/clipboard_aura_unittest.cc
+++ /dev/null
@@ -1,129 +0,0 @@
-// 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.
-
-#include "remoting/host/chromeos/clipboard_aura.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/message_loop/message_loop.h"
-#include "base/run_loop.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/test/test_timeouts.h"
-#include "remoting/base/constants.h"
-#include "remoting/proto/event.pb.h"
-#include "remoting/protocol/clipboard_stub.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/clipboard/clipboard.h"
-#include "ui/base/clipboard/scoped_clipboard_writer.h"
-
-using testing::_;
-using testing::Eq;
-using testing::InvokeWithoutArgs;
-using testing::Property;
-
-namespace remoting {
-
-namespace {
-
-const base::TimeDelta kTestOverridePollingInterval =
- base::TimeDelta::FromMilliseconds(1);
-
-class ClientClipboard : public protocol::ClipboardStub {
- public:
- ClientClipboard();
- MOCK_METHOD1(InjectClipboardEvent,
- void(const protocol::ClipboardEvent& event));
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ClientClipboard);
-};
-
-ClientClipboard::ClientClipboard() {
-}
-
-} // namespace
-
-class ClipboardAuraTest : public testing::Test {
- public:
- ClipboardAuraTest() {}
- void SetUp() override;
- void TearDown() override;
-
- protected:
- void StopAndResetClipboard();
-
- base::MessageLoopForUI message_loop_;
- base::RunLoop run_loop_;
- ClientClipboard* client_clipboard_;
- scoped_ptr<ClipboardAura> clipboard_;
-};
-
-void ClipboardAuraTest::SetUp() {
- // Alert the clipboard class to which threads are allowed to access the
- // clipboard.
- std::vector<base::PlatformThreadId> allowed_clipboard_threads;
- allowed_clipboard_threads.push_back(base::PlatformThread::CurrentId());
- ui::Clipboard::SetAllowedThreads(allowed_clipboard_threads);
-
- // Setup the clipboard.
- scoped_refptr<base::SingleThreadTaskRunner> task_runner =
- message_loop_.message_loop_proxy();
- client_clipboard_ = new ClientClipboard();
- clipboard_.reset(new ClipboardAura(task_runner));
- clipboard_->Start(make_scoped_ptr(client_clipboard_));
-
- EXPECT_GT(TestTimeouts::tiny_timeout(), kTestOverridePollingInterval * 10)
- << "The test timeout should be greater than the polling interval";
- clipboard_->SetPollingIntervalForTesting(kTestOverridePollingInterval);
-}
-
-void ClipboardAuraTest::TearDown() {
- ui::Clipboard::DestroyClipboardForCurrentThread();
-}
-
-void ClipboardAuraTest::StopAndResetClipboard() {
- clipboard_->Stop();
- clipboard_.reset();
-}
-
-TEST_F(ClipboardAuraTest, WriteToClipboard) {
- protocol::ClipboardEvent event;
- event.set_mime_type(kMimeTypeTextUtf8);
- event.set_data("Test data.");
-
- clipboard_->InjectClipboardEvent(event);
- StopAndResetClipboard();
- run_loop_.RunUntilIdle();
-
- std::string clipboard_data;
- ui::Clipboard* aura_clipboard = ui::Clipboard::GetForCurrentThread();
- aura_clipboard->ReadAsciiText(ui::CLIPBOARD_TYPE_COPY_PASTE, &clipboard_data);
-
- EXPECT_EQ(clipboard_data, "Test data.")
- << "InjectClipboardEvent should write to aura clipboard";
-}
-
-TEST_F(ClipboardAuraTest, MonitorClipboardChanges) {
- {
- // |clipboard_writer| will write to the clipboard when it goes out of scope.
- ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_COPY_PASTE);
- clipboard_writer.WriteText(base::UTF8ToUTF16("Test data."));
- }
-
- EXPECT_CALL(*client_clipboard_,
- InjectClipboardEvent(Property(&protocol::ClipboardEvent::data,
- Eq("Test data.")))).Times(1);
-
- message_loop_.PostDelayedTask(
- FROM_HERE, base::Bind(&ClipboardAuraTest_MonitorClipboardChanges_Test::
- StopAndResetClipboard,
- base::Unretained(this)),
- TestTimeouts::tiny_timeout());
- message_loop_.PostDelayedTask(FROM_HERE, base::MessageLoop::QuitClosure(),
- TestTimeouts::tiny_timeout());
- message_loop_.Run();
-}
-
-} // namespace remoting
« no previous file with comments | « remoting/host/chromeos/clipboard_aura.cc ('k') | remoting/host/chromeos/mouse_cursor_monitor_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698