summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/test/ui/ppapi_uitest.cc10
-rw-r--r--ppapi/ppapi_tests.gypi2
-rw-r--r--ppapi/tests/test_fullscreen.cc145
-rw-r--r--ppapi/tests/test_fullscreen.h41
4 files changed, 198 insertions, 0 deletions
diff --git a/chrome/test/ui/ppapi_uitest.cc b/chrome/test/ui/ppapi_uitest.cc
index f2b4df9..2217220 100644
--- a/chrome/test/ui/ppapi_uitest.cc
+++ b/chrome/test/ui/ppapi_uitest.cc
@@ -255,6 +255,16 @@ TEST_PPAPI_IN_PROCESS_VIA_HTTP(FileRef)
TEST_PPAPI_IN_PROCESS_VIA_HTTP(FileSystem)
TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(FileSystem)
+// http://crbug.com/96767
+#if !defined(OS_MACOSX)
+TEST_F(PPAPITest, FLAKY_Fullscreen) {
+ RunTestViaHTTP("Fullscreen");
+}
+TEST_F(OutOfProcessPPAPITest, FLAKY_Fullscreen) {
+ RunTestViaHTTP("Fullscreen");
+}
+#endif
+
#if defined(OS_POSIX)
#define MAYBE_DirectoryReader FLAKY_DirectoryReader
#else
diff --git a/ppapi/ppapi_tests.gypi b/ppapi/ppapi_tests.gypi
index 1f889b4..33735bc 100644
--- a/ppapi/ppapi_tests.gypi
+++ b/ppapi/ppapi_tests.gypi
@@ -90,6 +90,8 @@
'tests/test_cursor_control.h',
'tests/test_directory_reader.cc',
'tests/test_directory_reader.h',
+ 'tests/test_fullscreen.cc',
+ 'tests/test_fullscreen.h',
'tests/test_file_io.cc',
'tests/test_file_io.h',
'tests/test_file_ref.cc',
diff --git a/ppapi/tests/test_fullscreen.cc b/ppapi/tests/test_fullscreen.cc
new file mode 100644
index 0000000..3d41522
--- /dev/null
+++ b/ppapi/tests/test_fullscreen.cc
@@ -0,0 +1,145 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/tests/test_fullscreen.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <string>
+
+#include "ppapi/c/dev/ppb_testing_dev.h"
+#include "ppapi/c/dev/ppb_fullscreen_dev.h"
+#include "ppapi/cpp/dev/fullscreen_dev.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/rect.h"
+#include "ppapi/cpp/size.h"
+#include "ppapi/tests/test_utils.h"
+#include "ppapi/tests/testing_instance.h"
+
+REGISTER_TEST_CASE(Fullscreen);
+
+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);
+}
+
+} // namespace
+
+TestFullscreen::TestFullscreen(TestingInstance* instance)
+ : TestCase(instance),
+ screen_mode_(instance),
+ fullscreen_pending_(false),
+ normal_pending_(false),
+ fullscreen_callback_(instance->pp_instance()),
+ normal_callback_(instance->pp_instance()) {
+ screen_mode_.GetScreenSize(&screen_size_);
+}
+
+bool TestFullscreen::Init() {
+ return InitTestingInterface();
+}
+
+void TestFullscreen::RunTest() {
+ RUN_TEST(GetScreenSize);
+ RUN_TEST(NormalToFullscreenToNormal);
+}
+
+std::string TestFullscreen::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 TestFullscreen::TestNormalToFullscreenToNormal() {
+ // 0. Start in normal mode.
+ if (screen_mode_.IsFullscreen())
+ return ReportError("IsFullscreen() at start", true);
+
+ // 1. Switch to fullscreen.
+ // The transition is asynchronous and ends at the next DidChangeView().
+ // No graphics devices can be bound while in transition.
+ 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 (instance_->BindGraphics(graphics2d_fullscreen))
+ return ReportError("BindGraphics() in fullscreen transition", true);
+ if (screen_mode_.IsFullscreen())
+ return ReportError("IsFullscreen() in fullscreen transtion", true);
+
+ // DidChangeView() will call the callback once in fullscreen mode.
+ fullscreen_callback_.WaitForResult();
+ 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);
+
+ // 2. Stay in fullscreen. No change.
+ if (!screen_mode_.SetFullscreen(true))
+ return ReportError("SetFullscreen(true) in fullscreen", false);
+ if (!screen_mode_.IsFullscreen())
+ return ReportError("IsFullscreen() in fullscreen^2", false);
+
+ // 3. Switch to normal.
+ // The transition is synchronous in-process and asynchornous out-of-process
+ // because proxied IsFullscreen saves a roundtrip by relying on information
+ // communicated via a previous call to DidChangeView.
+ // Graphics devices can be bound right away.
+ 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_callback_.WaitForResult();
+ if (normal_pending_)
+ return "normal_pending_ has not been reset";
+ }
+ if (screen_mode_.IsFullscreen())
+ return ReportError("IsFullscreen() in normal", true);
+
+ // 4. Stay in normal. No change.
+ if (!screen_mode_.SetFullscreen(false))
+ return ReportError("SetFullscreen(false) in normal", false);
+ if (screen_mode_.IsFullscreen())
+ return ReportError("IsFullscreen() in normal^2", true);
+
+ PASS();
+}
+
+// Transition to fullscreen is asynchornous ending at DidChangeView.
+// Transition to normal is synchronous in-process and asynchronous
+// out-of-process ending at DidChangeView.
+void TestFullscreen::DidChangeView(const pp::Rect& position,
+ const pp::Rect& clip) {
+ if (fullscreen_pending_ && IsFullscreenView(position, clip, screen_size_)) {
+ fullscreen_pending_ = false;
+ pp::Module::Get()->core()->CallOnMainThread(0, fullscreen_callback_);
+ } else if (normal_pending_ &&
+ !IsFullscreenView(position, clip, screen_size_)) {
+ normal_pending_ = false;
+ if (testing_interface_->IsOutOfProcess())
+ pp::Module::Get()->core()->CallOnMainThread(0, normal_callback_);
+ }
+}
diff --git a/ppapi/tests/test_fullscreen.h b/ppapi/tests/test_fullscreen.h
new file mode 100644
index 0000000..c276ad5
--- /dev/null
+++ b/ppapi/tests/test_fullscreen.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PAPPI_TESTS_TEST_FULLSCREEN_H_
+#define PAPPI_TESTS_TEST_FULLSCREEN_H_
+
+#include <string>
+
+#include "ppapi/cpp/dev/fullscreen_dev.h"
+#include "ppapi/cpp/size.h"
+#include "ppapi/tests/test_case.h"
+#include "ppapi/tests/test_utils.h"
+
+namespace pp {
+class Rect;
+} // namespace pp
+
+class TestFullscreen : public TestCase {
+ public:
+ explicit TestFullscreen(TestingInstance* instance);
+
+ // TestCase implementation.
+ virtual bool Init();
+ virtual void RunTest();
+ virtual void DidChangeView(const pp::Rect& position, const pp::Rect& clip);
+
+ private:
+ std::string TestGetScreenSize();
+ std::string TestNormalToFullscreenToNormal();
+
+ pp::Fullscreen_Dev screen_mode_;
+ pp::Size screen_size_;
+
+ bool fullscreen_pending_;
+ bool normal_pending_;
+ TestCompletionCallback fullscreen_callback_;
+ TestCompletionCallback normal_callback_;
+};
+
+#endif // PAPPI_TESTS_TEST_FULLSCREEN_H_