| 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_fullscreen.h" | 5 #include "ppapi/tests/test_flash_fullscreen.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "ppapi/c/dev/ppb_testing_dev.h" | 11 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 12 #include "ppapi/c/dev/ppb_fullscreen_dev.h" | 12 #include "ppapi/c/private/ppb_flash_fullscreen.h" |
| 13 #include "ppapi/cpp/dev/fullscreen_dev.h" | |
| 14 #include "ppapi/cpp/graphics_2d.h" | 13 #include "ppapi/cpp/graphics_2d.h" |
| 15 #include "ppapi/cpp/instance.h" | 14 #include "ppapi/cpp/instance.h" |
| 16 #include "ppapi/cpp/module.h" | 15 #include "ppapi/cpp/module.h" |
| 17 #include "ppapi/cpp/point.h" | 16 #include "ppapi/cpp/point.h" |
| 17 #include "ppapi/cpp/private/flash_fullscreen.h" |
| 18 #include "ppapi/cpp/rect.h" | 18 #include "ppapi/cpp/rect.h" |
| 19 #include "ppapi/cpp/size.h" | 19 #include "ppapi/cpp/size.h" |
| 20 #include "ppapi/tests/test_utils.h" | 20 #include "ppapi/tests/test_utils.h" |
| 21 #include "ppapi/tests/testing_instance.h" | 21 #include "ppapi/tests/testing_instance.h" |
| 22 | 22 |
| 23 REGISTER_TEST_CASE(Fullscreen); | 23 REGISTER_TEST_CASE(FlashFullscreen); |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 bool IsFullscreenView(const pp::Rect& position, | 27 bool IsFullscreenView(const pp::Rect& position, |
| 28 const pp::Rect& clip, | 28 const pp::Rect& clip, |
| 29 const pp::Size& screen_size) { | 29 const pp::Size& screen_size) { |
| 30 return (position.point() == pp::Point(0, 0) && | 30 return (position.point() == pp::Point(0, 0) && |
| 31 position.size() == screen_size && | 31 position.size() == screen_size && |
| 32 clip.point() == pp::Point(0, 0) && | 32 clip.point() == pp::Point(0, 0) && |
| 33 clip.size() == screen_size); | 33 clip.size() == screen_size); |
| 34 } | 34 } |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 TestFullscreen::TestFullscreen(TestingInstance* instance) | 38 TestFlashFullscreen::TestFlashFullscreen(TestingInstance* instance) |
| 39 : TestCase(instance), | 39 : TestCase(instance), |
| 40 screen_mode_(instance), | 40 screen_mode_(instance), |
| 41 fullscreen_pending_(false), | 41 fullscreen_pending_(false), |
| 42 normal_pending_(false), | 42 normal_pending_(false), |
| 43 fullscreen_callback_(instance->pp_instance()), | 43 fullscreen_callback_(instance->pp_instance()), |
| 44 normal_callback_(instance->pp_instance()) { | 44 normal_callback_(instance->pp_instance()) { |
| 45 screen_mode_.GetScreenSize(&screen_size_); | 45 screen_mode_.GetScreenSize(&screen_size_); |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool TestFullscreen::Init() { | 48 bool TestFlashFullscreen::Init() { |
| 49 return InitTestingInterface(); | 49 return InitTestingInterface(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void TestFullscreen::RunTest() { | 52 void TestFlashFullscreen::RunTest() { |
| 53 RUN_TEST(GetScreenSize); | 53 RUN_TEST(GetScreenSize); |
| 54 RUN_TEST(NormalToFullscreenToNormal); | 54 RUN_TEST(NormalToFullscreenToNormal); |
| 55 } | 55 } |
| 56 | 56 |
| 57 std::string TestFullscreen::TestGetScreenSize() { | 57 std::string TestFlashFullscreen::TestGetScreenSize() { |
| 58 if (screen_size_.width() < 320 || screen_size_.width() > 2560) | 58 if (screen_size_.width() < 320 || screen_size_.width() > 2560) |
| 59 return ReportError("screen_size.width()", screen_size_.width()); | 59 return ReportError("screen_size.width()", screen_size_.width()); |
| 60 if (screen_size_.height() < 200 || screen_size_.height() > 2048) | 60 if (screen_size_.height() < 200 || screen_size_.height() > 2048) |
| 61 return ReportError("screen_size.height()", screen_size_.height()); | 61 return ReportError("screen_size.height()", screen_size_.height()); |
| 62 PASS(); | 62 PASS(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 std::string TestFullscreen::TestNormalToFullscreenToNormal() { | 65 std::string TestFlashFullscreen::TestNormalToFullscreenToNormal() { |
| 66 // 0. Start in normal mode. | 66 // 0. Start in normal mode. |
| 67 if (screen_mode_.IsFullscreen()) | 67 if (screen_mode_.IsFullscreen()) |
| 68 return ReportError("IsFullscreen() at start", true); | 68 return ReportError("IsFullscreen() at start", true); |
| 69 | 69 |
| 70 // 1. Switch to fullscreen. | 70 // 1. Switch to fullscreen. |
| 71 // The transition is asynchronous and ends at the next DidChangeView(). | 71 // The transition is asynchronous and ends at the next DidChangeView(). |
| 72 // No graphics devices can be bound while in transition. | 72 // No graphics devices can be bound while in transition. |
| 73 fullscreen_pending_ = true; | 73 fullscreen_pending_ = true; |
| 74 if (!screen_mode_.SetFullscreen(true)) | 74 if (!screen_mode_.SetFullscreen(true)) |
| 75 return ReportError("SetFullscreen(true) in normal", false); | 75 return ReportError("SetFullscreen(true) in normal", false); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 return ReportError("SetFullscreen(false) in normal", false); | 124 return ReportError("SetFullscreen(false) in normal", false); |
| 125 if (screen_mode_.IsFullscreen()) | 125 if (screen_mode_.IsFullscreen()) |
| 126 return ReportError("IsFullscreen() in normal^2", true); | 126 return ReportError("IsFullscreen() in normal^2", true); |
| 127 | 127 |
| 128 PASS(); | 128 PASS(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 // Transition to fullscreen is asynchornous ending at DidChangeView. | 131 // Transition to fullscreen is asynchornous ending at DidChangeView. |
| 132 // Transition to normal is synchronous in-process and asynchronous | 132 // Transition to normal is synchronous in-process and asynchronous |
| 133 // out-of-process ending at DidChangeView. | 133 // out-of-process ending at DidChangeView. |
| 134 void TestFullscreen::DidChangeView(const pp::Rect& position, | 134 void TestFlashFullscreen::DidChangeView(const pp::Rect& position, |
| 135 const pp::Rect& clip) { | 135 const pp::Rect& clip) { |
| 136 if (fullscreen_pending_ && IsFullscreenView(position, clip, screen_size_)) { | 136 if (fullscreen_pending_ && IsFullscreenView(position, clip, screen_size_)) { |
| 137 fullscreen_pending_ = false; | 137 fullscreen_pending_ = false; |
| 138 pp::Module::Get()->core()->CallOnMainThread(0, fullscreen_callback_); | 138 pp::Module::Get()->core()->CallOnMainThread(0, fullscreen_callback_); |
| 139 } else if (normal_pending_ && | 139 } else if (normal_pending_ && |
| 140 !IsFullscreenView(position, clip, screen_size_)) { | 140 !IsFullscreenView(position, clip, screen_size_)) { |
| 141 normal_pending_ = false; | 141 normal_pending_ = false; |
| 142 if (testing_interface_->IsOutOfProcess()) | 142 if (testing_interface_->IsOutOfProcess()) |
| 143 pp::Module::Get()->core()->CallOnMainThread(0, normal_callback_); | 143 pp::Module::Get()->core()->CallOnMainThread(0, normal_callback_); |
| 144 } | 144 } |
| 145 } | 145 } |
| OLD | NEW |