OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ppapi/tests/test_flash_clipboard.h" | |
6 | |
7 #include "ppapi/cpp/instance.h" | |
8 #include "ppapi/cpp/module.h" | |
9 #include "ppapi/cpp/point.h" | |
10 #include "ppapi/tests/testing_instance.h" | |
11 | |
12 REGISTER_TEST_CASE(FlashClipboard); | |
13 | |
14 TestFlashClipboard::TestFlashClipboard(TestingInstance* instance) | |
15 : TestCase(instance), | |
16 clipboard_interface_(NULL) { | |
17 } | |
18 | |
19 bool TestFlashClipboard::Init() { | |
20 clipboard_interface_ = static_cast<const PPB_Flash_Clipboard*>( | |
21 pp::Module::Get()->GetBrowserInterface(PPB_FLASH_CLIPBOARD_INTERFACE)); | |
22 return !!clipboard_interface_; | |
23 } | |
24 | |
25 void TestFlashClipboard::RunTest() { | |
26 RUN_TEST(ReadWrite); | |
27 } | |
28 | |
29 std::string TestFlashClipboard::TestReadWrite() { | |
30 std::string input_str("Hello, world"); | |
31 pp::Var input_var(input_str); | |
32 clipboard_interface_->WritePlainText(instance_->pp_instance(), | |
33 PP_FLASH_CLIPBOARD_TYPE_STANDARD, | |
34 input_var.pp_var()); | |
35 | |
viettrungluu
2011/10/20 23:41:01
Can you also add a test to check IsFormatAvailable
| |
36 pp::Var result_var(pp::Var::PassRef(), | |
37 clipboard_interface_->ReadPlainText(instance_->pp_instance(), | |
38 PP_FLASH_CLIPBOARD_TYPE_STANDARD)); | |
39 ASSERT_TRUE(result_var.is_string()); | |
40 | |
41 std::string result_str = result_var.AsString(); | |
42 ASSERT_TRUE(result_str == input_str); | |
43 PASS(); | |
44 } | |
OLD | NEW |