| Index: ppapi/tests/test_flash_clipboard.cc
|
| diff --git a/ppapi/tests/test_flash_clipboard.cc b/ppapi/tests/test_flash_clipboard.cc
|
| index 76803b067e4fa825705acac4bab99405d47c114c..8d0db5ad4f5431359fe468063771a93c358f0fe1 100644
|
| --- a/ppapi/tests/test_flash_clipboard.cc
|
| +++ b/ppapi/tests/test_flash_clipboard.cc
|
| @@ -4,12 +4,15 @@
|
|
|
| #include "ppapi/tests/test_flash_clipboard.h"
|
|
|
| +#include <algorithm>
|
| #include <vector>
|
|
|
| #include "ppapi/cpp/instance.h"
|
| #include "ppapi/cpp/module.h"
|
| #include "ppapi/cpp/point.h"
|
| #include "ppapi/cpp/private/flash_clipboard.h"
|
| +#include "ppapi/cpp/var.h"
|
| +#include "ppapi/cpp/var_array_buffer.h"
|
| #include "ppapi/tests/testing_instance.h"
|
|
|
| REGISTER_TEST_CASE(FlashClipboard);
|
| @@ -27,6 +30,7 @@ TestFlashClipboard::TestFlashClipboard(TestingInstance* instance)
|
| void TestFlashClipboard::RunTests(const std::string& filter) {
|
| RUN_TEST(ReadWritePlainText, filter);
|
| RUN_TEST(ReadWriteHTML, filter);
|
| + RUN_TEST(ReadWriteRTF, filter);
|
| RUN_TEST(ReadWriteMultipleFormats, filter);
|
| RUN_TEST(Clear, filter);
|
| }
|
| @@ -115,6 +119,41 @@ std::string TestFlashClipboard::TestReadWriteHTML() {
|
| PASS();
|
| }
|
|
|
| +std::string TestFlashClipboard::TestReadWriteRTF() {
|
| + std::string rtf_string =
|
| + "{\\rtf1\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\f0\\pard\n"
|
| + "This is some {\\b bold} text.\\par\n"
|
| + "}";
|
| + pp::VarArrayBuffer array_buffer(rtf_string.size());
|
| + char *bytes = static_cast<char*>(array_buffer.Map());
|
| + std::copy(rtf_string.data(), rtf_string.data() + rtf_string.size(), bytes);
|
| + std::vector<PP_Flash_Clipboard_Format> formats_vector(1,
|
| + PP_FLASH_CLIPBOARD_FORMAT_RTF);
|
| + std::vector<pp::Var> data_vector(1, array_buffer);
|
| + ASSERT_TRUE(pp::flash::Clipboard::WriteData(
|
| + instance_,
|
| + PP_FLASH_CLIPBOARD_TYPE_STANDARD,
|
| + formats_vector,
|
| + data_vector));
|
| +
|
| + ASSERT_TRUE(IsFormatAvailableMatches(PP_FLASH_CLIPBOARD_FORMAT_RTF, true));
|
| +
|
| + pp::Var rtf_result;
|
| + ASSERT_TRUE(pp::flash::Clipboard::ReadData(
|
| + instance_,
|
| + PP_FLASH_CLIPBOARD_TYPE_STANDARD,
|
| + PP_FLASH_CLIPBOARD_FORMAT_RTF,
|
| + &rtf_result));
|
| + ASSERT_TRUE(rtf_result.is_array_buffer());
|
| + pp::VarArrayBuffer array_buffer_result(rtf_result);
|
| + ASSERT_TRUE(array_buffer_result.ByteLength() == array_buffer.ByteLength());
|
| + char *bytes_result = static_cast<char*>(array_buffer_result.Map());
|
| + ASSERT_TRUE(std::equal(bytes, bytes + array_buffer.ByteLength(),
|
| + bytes_result));
|
| +
|
| + PASS();
|
| +}
|
| +
|
| std::string TestFlashClipboard::TestReadWriteMultipleFormats() {
|
| std::vector<PP_Flash_Clipboard_Format> formats;
|
| std::vector<pp::Var> data;
|
|
|