This source file includes following definitions.
- IsFullscreenView
- normal_event_
- Init
- RunTests
- TestGetScreenSize
- TestNormalToFullscreenToNormal
- DidChangeView
#include "ppapi/tests/test_flash_fullscreen.h"
#include <stdio.h>
#include <string.h>
#include <string>
#include "ppapi/c/private/ppb_flash_fullscreen.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/point.h"
#include "ppapi/cpp/private/flash_fullscreen.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/size.h"
#include "ppapi/tests/test_utils.h"
#include "ppapi/tests/testing_instance.h"
REGISTER_TEST_CASE(FlashFullscreen);
namespace {
bool IsFullscreenView(const pp::Rect& position,
const pp::Rect& clip,
const pp::Size& screen_size) {
return (position.point() == pp::Point(0, 0) &&
position.size() == screen_size &&
clip.point() == pp::Point(0, 0) &&
clip.size() == screen_size);
}
}
TestFlashFullscreen::TestFlashFullscreen(TestingInstance* instance)
: TestCase(instance),
screen_mode_(instance),
fullscreen_pending_(false),
normal_pending_(false),
fullscreen_event_(instance->pp_instance()),
normal_event_(instance->pp_instance()) {
screen_mode_.GetScreenSize(&screen_size_);
}
bool TestFlashFullscreen::Init() {
return CheckTestingInterface();
}
void TestFlashFullscreen::RunTests(const std::string& filter) {
RUN_TEST(GetScreenSize, filter);
RUN_TEST(NormalToFullscreenToNormal, filter);
}
std::string TestFlashFullscreen::TestGetScreenSize() {
if (screen_size_.width() < 320 || screen_size_.width() > 2560)
return ReportError("screen_size.width()", screen_size_.width());
if (screen_size_.height() < 200 || screen_size_.height() > 2048)
return ReportError("screen_size.height()", screen_size_.height());
PASS();
}
std::string TestFlashFullscreen::TestNormalToFullscreenToNormal() {
if (screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() at start", true);
fullscreen_pending_ = true;
if (!screen_mode_.SetFullscreen(true))
return ReportError("SetFullscreen(true) in normal", false);
pp::Graphics2D graphics2d_fullscreen(instance_, pp::Size(10, 10), false);
if (graphics2d_fullscreen.is_null())
return "Failed to create graphics2d_fullscreen";
if (!testing_interface_->IsOutOfProcess()) {
if (instance_->BindGraphics(graphics2d_fullscreen))
return ReportError("BindGraphics() in fullscreen transition", true);
if (screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in fullscreen transtion", true);
}
fullscreen_event_.Wait();
if (fullscreen_pending_)
return "fullscreen_pending_ has not been reset";
if (!screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in fullscreen", false);
if (!instance_->BindGraphics(graphics2d_fullscreen))
return ReportError("BindGraphics() in fullscreen", false);
if (!screen_mode_.SetFullscreen(true))
return ReportError("SetFullscreen(true) in fullscreen", false);
if (!screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in fullscreen^2", false);
normal_pending_ = true;
if (!screen_mode_.SetFullscreen(false))
return ReportError("SetFullscreen(false) in fullscreen", false);
pp::Graphics2D graphics2d_normal(instance_, pp::Size(15, 15), false);
if (graphics2d_normal.is_null())
return "Failed to create graphics2d_normal";
if (!instance_->BindGraphics(graphics2d_normal))
return ReportError("BindGraphics() in normal transition", false);
if (testing_interface_->IsOutOfProcess()) {
if (!screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in normal transition", false);
normal_event_.Wait();
if (normal_pending_)
return "normal_pending_ has not been reset";
}
if (screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in normal", true);
if (!screen_mode_.SetFullscreen(false))
return ReportError("SetFullscreen(false) in normal", false);
if (screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in normal^2", true);
PASS();
}
void TestFlashFullscreen::DidChangeView(const pp::View& view) {
pp::Rect position = view.GetRect();
pp::Rect clip = view.GetClipRect();
if (fullscreen_pending_ && IsFullscreenView(position, clip, screen_size_)) {
fullscreen_pending_ = false;
fullscreen_event_.Signal();
} else if (normal_pending_ &&
!IsFullscreenView(position, clip, screen_size_)) {
normal_pending_ = false;
if (testing_interface_->IsOutOfProcess())
normal_event_.Signal();
}
}