| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/tests/test_flash_clipboard.h" | 5 #include "ppapi/tests/test_flash_clipboard.h" |
| 6 | 6 |
| 7 #include "ppapi/cpp/instance.h" | 7 #include "ppapi/cpp/instance.h" |
| 8 #include "ppapi/cpp/module.h" | 8 #include "ppapi/cpp/module.h" |
| 9 #include "ppapi/cpp/point.h" | 9 #include "ppapi/cpp/point.h" |
| 10 #include "ppapi/tests/testing_instance.h" | 10 #include "ppapi/tests/testing_instance.h" |
| 11 | 11 |
| 12 REGISTER_TEST_CASE(FlashClipboard); | 12 REGISTER_TEST_CASE(FlashClipboard); |
| 13 | 13 |
| 14 TestFlashClipboard::TestFlashClipboard(TestingInstance* instance) | 14 TestFlashClipboard::TestFlashClipboard(TestingInstance* instance) |
| 15 : TestCase(instance), | 15 : TestCase(instance), |
| 16 clipboard_interface_(NULL) { | 16 clipboard_interface_(NULL) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 bool TestFlashClipboard::Init() { | 19 bool TestFlashClipboard::Init() { |
| 20 clipboard_interface_ = static_cast<const PPB_Flash_Clipboard*>( | 20 clipboard_interface_ = static_cast<const PPB_Flash_Clipboard*>( |
| 21 pp::Module::Get()->GetBrowserInterface(PPB_FLASH_CLIPBOARD_INTERFACE)); | 21 pp::Module::Get()->GetBrowserInterface(PPB_FLASH_CLIPBOARD_INTERFACE)); |
| 22 return !!clipboard_interface_; | 22 return !!clipboard_interface_; |
| 23 } | 23 } |
| 24 | 24 |
| 25 void TestFlashClipboard::RunTest() { | 25 void TestFlashClipboard::RunTests(const std::string& filter) { |
| 26 RUN_TEST(ReadWrite); | 26 RUN_TEST(ReadWrite, filter); |
| 27 } | 27 } |
| 28 | 28 |
| 29 std::string TestFlashClipboard::TestReadWrite() { | 29 std::string TestFlashClipboard::TestReadWrite() { |
| 30 std::string input_str("Hello, world"); | 30 std::string input_str("Hello, world"); |
| 31 pp::Var input_var(input_str); | 31 pp::Var input_var(input_str); |
| 32 clipboard_interface_->WritePlainText(instance_->pp_instance(), | 32 clipboard_interface_->WritePlainText(instance_->pp_instance(), |
| 33 PP_FLASH_CLIPBOARD_TYPE_STANDARD, | 33 PP_FLASH_CLIPBOARD_TYPE_STANDARD, |
| 34 input_var.pp_var()); | 34 input_var.pp_var()); |
| 35 | 35 |
| 36 ASSERT_TRUE(clipboard_interface_->IsFormatAvailable( | 36 ASSERT_TRUE(clipboard_interface_->IsFormatAvailable( |
| 37 instance_->pp_instance(), | 37 instance_->pp_instance(), |
| 38 PP_FLASH_CLIPBOARD_TYPE_STANDARD, | 38 PP_FLASH_CLIPBOARD_TYPE_STANDARD, |
| 39 PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT)); | 39 PP_FLASH_CLIPBOARD_FORMAT_PLAINTEXT)); |
| 40 | 40 |
| 41 pp::Var result_var(pp::Var::PassRef(), | 41 pp::Var result_var(pp::Var::PassRef(), |
| 42 clipboard_interface_->ReadPlainText(instance_->pp_instance(), | 42 clipboard_interface_->ReadPlainText(instance_->pp_instance(), |
| 43 PP_FLASH_CLIPBOARD_TYPE_STANDARD)); | 43 PP_FLASH_CLIPBOARD_TYPE_STANDARD)); |
| 44 ASSERT_TRUE(result_var.is_string()); | 44 ASSERT_TRUE(result_var.is_string()); |
| 45 | 45 |
| 46 std::string result_str = result_var.AsString(); | 46 std::string result_str = result_var.AsString(); |
| 47 ASSERT_TRUE(result_str == input_str); | 47 ASSERT_TRUE(result_str == input_str); |
| 48 PASS(); | 48 PASS(); |
| 49 } | 49 } |
| OLD | NEW |