Commit a6ff5bd4 authored by Antoine Labour's avatar Antoine Labour Committed by Commit Bot

Remove use of PPB_Compositor in TestFlashFullscreenForBrowserUI

PPB_Compositor is going away, so replace with PPB_Graphics3D. Also fix
logic related to submitting frames while callbacks are pending (might be
related to test flakiness).

Bug: 918951
Change-Id: I232c87525f39e268c6fd26072cb465c07fc4256b
Reviewed-on: https://chromium-review.googlesource.com/c/1395144Reviewed-by: default avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619980}
parent 77a25c0f
......@@ -4,6 +4,9 @@
#include "ppapi/tests/test_flash_fullscreen_for_browser_ui.h"
#include <GLES2/gl2.h>
#include "ppapi/c/ppb_opengles2.h"
#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/rect.h"
......@@ -16,8 +19,6 @@ TestFlashFullscreenForBrowserUI::
: TestCase(instance),
screen_mode_(instance),
view_change_event_(instance->pp_instance()),
num_trigger_events_(0),
request_fullscreen_(false),
callback_factory_(this) {
// This plugin should not be removed after this TestCase passes because
// browser UI testing requires it to remain and to be interactive.
......@@ -28,7 +29,9 @@ TestFlashFullscreenForBrowserUI::~TestFlashFullscreenForBrowserUI() {
}
bool TestFlashFullscreenForBrowserUI::Init() {
return CheckTestingInterface();
opengl_es2_ = static_cast<const PPB_OpenGLES2*>(
pp::Module::Get()->GetBrowserInterface(PPB_OPENGLES2_INTERFACE));
return opengl_es2_ && CheckTestingInterface();
}
void TestFlashFullscreenForBrowserUI::RunTests(const std::string& filter) {
......@@ -43,6 +46,18 @@ std::string TestFlashFullscreenForBrowserUI::TestEnterFullscreen() {
if (screen_mode_.SetFullscreen(true))
return ReportError("SetFullscreen(true) outside of user gesture", true);
int32_t attribs[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 8,
PP_GRAPHICS3DATTRIB_GREEN_SIZE, 8,
PP_GRAPHICS3DATTRIB_BLUE_SIZE, 8,
PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 0,
PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 0,
PP_GRAPHICS3DATTRIB_WIDTH, layer_size_.width(),
PP_GRAPHICS3DATTRIB_HEIGHT, layer_size_.height(),
PP_GRAPHICS3DATTRIB_NONE};
graphics_3d_ = pp::Graphics3D(instance_, attribs);
instance_->BindGraphics(graphics_3d_);
// Trigger another call to SetFullscreen(true) from HandleInputEvent().
// The transition is asynchronous and ends at the next DidChangeView().
view_change_event_.Reset();
......@@ -57,10 +72,6 @@ std::string TestFlashFullscreenForBrowserUI::TestEnterFullscreen() {
if (!screen_mode_.IsFullscreen())
return ReportError("IsFullscreen() in fullscreen", false);
compositor_ = pp::Compositor(instance_);
instance_->BindGraphics(compositor_);
color_layer_ = compositor_.AddLayer();
const int32_t result =
instance_->RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_MOUSE |
PP_INPUTEVENT_CLASS_KEYBOARD);
......@@ -75,8 +86,10 @@ void TestFlashFullscreenForBrowserUI::DidChangeView(const pp::View& view) {
if (normal_position_.IsEmpty())
normal_position_ = view.GetRect();
if (!compositor_.is_null())
Paint(PP_OK);
if (!graphics_3d_.is_null()) {
graphics_3d_.ResizeBuffers(layer_size_.width(), layer_size_.height());
RequestPaint();
}
view_change_event_.Signal();
}
......@@ -142,18 +155,36 @@ bool TestFlashFullscreenForBrowserUI::HandleInputEvent(
}
++num_trigger_events_;
RequestPaint();
return true;
}
void TestFlashFullscreenForBrowserUI::Paint(int32_t last_compositor_result) {
void TestFlashFullscreenForBrowserUI::RequestPaint() {
if (swap_pending_)
needs_paint_ = true;
else
DoPaint();
}
void TestFlashFullscreenForBrowserUI::DoPaint() {
if (num_trigger_events_ == 0)
color_layer_.SetColor(0.0f, 1.0f, 0.0f, 1.0f, layer_size_);
opengl_es2_->ClearColor(graphics_3d_.pp_resource(), 0.0f, 1.0f, 0.0f, 1.0f);
else if (num_trigger_events_ % 2)
color_layer_.SetColor(1.0f, 0.0f, 0.0f, 1.0f, layer_size_);
opengl_es2_->ClearColor(graphics_3d_.pp_resource(), 1.0f, 0.0f, 0.0f, 1.0f);
else
color_layer_.SetColor(0.0f, 0.0f, 1.0f, 1.0f, layer_size_);
opengl_es2_->ClearColor(graphics_3d_.pp_resource(), 0.0f, 0.0f, 1.0f, 1.0f);
compositor_.CommitLayers(
callback_factory_.NewCallback(&TestFlashFullscreenForBrowserUI::Paint));
opengl_es2_->Clear(graphics_3d_.pp_resource(), GL_COLOR_BUFFER_BIT);
swap_pending_ = true;
graphics_3d_.SwapBuffers(
callback_factory_.NewCallback(&TestFlashFullscreenForBrowserUI::DidSwap));
}
void TestFlashFullscreenForBrowserUI::DidSwap(int32_t last_compositor_result) {
swap_pending_ = false;
if (needs_paint_) {
needs_paint_ = false;
DoPaint();
}
}
......@@ -9,14 +9,15 @@
#include <string>
#include "ppapi/cpp/compositor.h"
#include "ppapi/cpp/compositor_layer.h"
#include "ppapi/cpp/graphics_3d.h"
#include "ppapi/cpp/private/flash_fullscreen.h"
#include "ppapi/cpp/size.h"
#include "ppapi/tests/test_case.h"
#include "ppapi/tests/test_utils.h"
#include "ppapi/utility/completion_callback_factory.h"
struct PPB_OpenGLES2;
// This is a special TestCase whose purpose is *not* to test the correctness of
// the Pepper APIs. Instead, this is a simulated Flash plugin, used to place
// the browser window and other UI elements into Flash Fullscreen mode for
......@@ -41,24 +42,30 @@ class TestFlashFullscreenForBrowserUI : public TestCase {
private:
std::string TestEnterFullscreen();
void Paint(int32_t last_compositor_result);
void RequestPaint();
void DoPaint();
void DidSwap(int32_t last_compositor_result);
void SimulateUserGesture();
bool GotError();
std::string Error();
void FailFullscreenTest(const std::string& error);
// OpenGL ES2 interface.
const PPB_OpenGLES2* opengl_es2_ = nullptr;
std::string error_;
pp::FlashFullscreen screen_mode_;
NestedEvent view_change_event_;
pp::Compositor compositor_;
pp::Graphics3D graphics_3d_;
pp::Size layer_size_;
pp::CompositorLayer color_layer_;
pp::Rect normal_position_;
int num_trigger_events_;
bool request_fullscreen_;
int num_trigger_events_ = 0;
bool request_fullscreen_ = false;
bool swap_pending_ = false;
bool needs_paint_ = false;
pp::CompletionCallbackFactory<TestFlashFullscreenForBrowserUI>
callback_factory_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment