Commit ed7d2f61 authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Use virtual clipboard for tests

Using the system clipboard for tests causes race conditions (it's a
shared resource), means that tests pollute global state, and causes
tests to fail on Windows if the workstation is locked (opening the
clipboard fails in that case). So, using the TestClipboard is important.

This was tested by running this command:
    unit_tests --gtest_filter=SharedClipboardMessageHandlerTest*
Before the clipboard contents were perturbed. After, they were not.

Bug: 996325
Change-Id: Idec21ce709463bcd9c70d7d25f1a6bc851170ba1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1881988
Auto-Submit: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Michael van Ouwerkerk <mvanouwerkerk@chromium.org>
Reviewed-by: default avatarMichael van Ouwerkerk <mvanouwerkerk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710727}
parent 399cc06b
......@@ -21,6 +21,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/test/test_clipboard.h"
#include "ui/base/l10n/l10n_util.h"
namespace {
......@@ -40,6 +41,7 @@ class SharedClipboardMessageHandlerTest : public testing::Test {
sharing_service_ = std::make_unique<MockSharingService>();
message_handler_ = std::make_unique<SharedClipboardMessageHandlerDesktop>(
sharing_service_.get(), notification_display_service_.get());
ui::TestClipboard::CreateForCurrentThread();
}
void TearDown() override {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment