Chromium Code Reviews| 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.h" | |
| 6 | |
| 7 #include "base/compiler_specific.h" | |
| 8 #include "ppapi/c/private/ppb_flash.h" | |
| 9 #include "ppapi/cpp/instance.h" | |
| 10 #include "ppapi/cpp/module.h" | |
| 11 #include "ppapi/cpp/var.h" | |
| 12 #include "ppapi/tests/testing_instance.h" | |
| 13 | |
| 14 REGISTER_TEST_CASE(Flash); | |
| 15 | |
| 16 using pp::Var; | |
| 17 | |
| 18 TestFlash::TestFlash(TestingInstance* instance) | |
| 19 : TestCase(instance), | |
| 20 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) { | |
| 21 } | |
| 22 | |
| 23 bool TestFlash::Init() { | |
| 24 flash_interface_ = reinterpret_cast<PPB_Flash const*>( | |
|
yzshen1
2011/11/17 01:39:45
nit: maybe it is better to keep const at the same
dmichael (off chromium)
2011/11/17 04:10:46
static_cast
viettrungluu
2011/11/17 19:13:39
Done.
viettrungluu
2011/11/17 19:13:39
Done.
| |
| 25 pp::Module::Get()->GetBrowserInterface(PPB_FLASH_INTERFACE)); | |
| 26 return !!flash_interface_; | |
| 27 } | |
| 28 | |
| 29 void TestFlash::RunTest() { | |
|
yzshen1
2011/11/17 01:39:45
I thought a filter string is needed?
viettrungluu
2011/11/17 19:13:39
Yeah, I was working off a stale tree and rebasing
| |
| 30 RUN_TEST(SetInstanceAlwaysOnTop); | |
| 31 RUN_TEST(GetProxyForURL); | |
| 32 RUN_TEST(MessageLoop); | |
| 33 RUN_TEST(GetLocalTimeZoneOffset); | |
| 34 RUN_TEST(GetCommandLineArgs); | |
| 35 } | |
| 36 | |
| 37 std::string TestFlash::TestSetInstanceAlwaysOnTop() { | |
| 38 flash_interface_->SetInstanceAlwaysOnTop(instance_->pp_instance(), PP_TRUE); | |
| 39 flash_interface_->SetInstanceAlwaysOnTop(instance_->pp_instance(), PP_FALSE); | |
| 40 PASS(); | |
| 41 } | |
| 42 | |
| 43 std::string TestFlash::TestGetProxyForURL() { | |
| 44 Var result(Var::PassRef(), | |
| 45 flash_interface_->GetProxyForURL(instance_->pp_instance(), | |
| 46 "http://127.0.0.1/foobar/")); | |
| 47 ASSERT_TRUE(result.is_string()); | |
| 48 // Assume no one configures a proxy for localhost. | |
| 49 ASSERT_EQ("DIRECT", result.AsString()); | |
| 50 | |
| 51 result = Var(Var::PassRef(), | |
| 52 flash_interface_->GetProxyForURL(instance_->pp_instance(), | |
| 53 "http://www.google.com")); | |
| 54 // Don't know what the proxy might be, but it should be a valid result. | |
| 55 ASSERT_TRUE(result.is_string()); | |
| 56 | |
| 57 result = Var(Var::PassRef(), | |
| 58 flash_interface_->GetProxyForURL(instance_->pp_instance(), | |
| 59 "file:///tmp")); | |
| 60 ASSERT_TRUE(result.is_string()); | |
| 61 // Should get "DIRECT" for file:// URLs. | |
| 62 ASSERT_EQ("DIRECT", result.AsString()); | |
| 63 | |
| 64 result = Var(Var::PassRef(), | |
| 65 flash_interface_->GetProxyForURL(instance_->pp_instance(), | |
| 66 "this_isnt_an_url")); | |
| 67 // Should be an error. | |
| 68 ASSERT_TRUE(result.is_undefined()); | |
| 69 | |
| 70 PASS(); | |
| 71 } | |
| 72 | |
| 73 std::string TestFlash::TestMessageLoop() { | |
| 74 pp::CompletionCallback callback = | |
| 75 callback_factory_.NewRequiredCallback(&TestFlash::QuitMessageLoopTask); | |
| 76 pp::Module::Get()->core()->CallOnMainThread(0, callback); | |
| 77 flash_interface_->RunMessageLoop(instance_->pp_instance()); | |
| 78 | |
| 79 PASS(); | |
| 80 } | |
| 81 | |
| 82 std::string TestFlash::TestGetLocalTimeZoneOffset() { | |
| 83 double result = flash_interface_->GetLocalTimeZoneOffset( | |
| 84 instance_->pp_instance(), 1321491298.0); | |
| 85 // The result depends on the local time zone, but +/- 14h from UTC should | |
| 86 // cover the possibilities. | |
| 87 ASSERT_TRUE(result >= -14 * 60 * 60); | |
| 88 ASSERT_TRUE(result <= 14 * 60 * 60); | |
| 89 | |
| 90 PASS(); | |
| 91 } | |
| 92 | |
| 93 std::string TestFlash::TestGetCommandLineArgs() { | |
| 94 Var result(Var::PassRef(), | |
| 95 flash_interface_->GetCommandLineArgs( | |
| 96 pp::Module::Get()->pp_module())); | |
| 97 ASSERT_TRUE(result.is_string()); | |
| 98 | |
| 99 PASS(); | |
| 100 } | |
| 101 | |
| 102 void TestFlash::QuitMessageLoopTask(int32_t) { | |
| 103 flash_interface_->QuitMessageLoop(instance_->pp_instance()); | |
| 104 } | |
| OLD | NEW |