1 // Copyright 2016 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "base/run_loop.h" 6 #include "base/strings/utf_string_conversions.h" 7 #include "build/build_config.h" 8 #include "content/public/browser/render_frame_host.h" 9 #include "content/public/browser/web_contents.h" 10 #include "content/public/test/browser_test_utils.h" 11 #include "content/public/test/content_browser_test.h" 12 #include "content/public/test/content_browser_test_utils.h" 13 #include "content/shell/browser/shell.h" 14 15 namespace content { 16 17 namespace { 18 19 class WebClipboardImplTest : public ContentBrowserTest { 20 public: 21 WebClipboardImplTest() = default; 22 ~WebClipboardImplTest() override = default; 23 }; 24 IN_PROC_BROWSER_TEST_F(WebClipboardImplTest,PasteRTF)25IN_PROC_BROWSER_TEST_F(WebClipboardImplTest, PasteRTF) { 26 BrowserTestClipboardScope clipboard; 27 28 const std::string rtf_content = "{\\rtf1\\ansi Hello, {\\b world.}}"; 29 clipboard.SetRtf(rtf_content); 30 31 FrameFocusedObserver focus_observer(shell()->web_contents()->GetMainFrame()); 32 // paste_listener.html takes RTF from the clipboard and sets the title. 33 EXPECT_TRUE(NavigateToURL(shell(), GetTestUrl(".", "paste_listener.html"))); 34 focus_observer.Wait(); 35 36 const base::string16 expected_title = base::UTF8ToUTF16(rtf_content); 37 TitleWatcher title_watcher(shell()->web_contents(), expected_title); 38 shell()->web_contents()->Paste(); 39 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 40 } 41 42 } // namespace 43 44 } // namespace content 45