From c6da0bcc3876339b7c78e8306856ca4de395e5a9 Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Wed, 11 Apr 2012 23:10:36 +0000 Subject: Fix line endings in ppapi. No code change. BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10052028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131869 0039d316-1c4b-4281-b951-d872f2087c98 --- ppapi/api/ppb_mouse_cursor.idl | 212 +++++++-------- ppapi/cpp/mouse_cursor.cc | 62 ++--- ppapi/cpp/mouse_cursor.h | 112 ++++---- ppapi/examples/mouse_cursor/mouse_cursor.cc | 10 +- ppapi/tests/test_page.css | 134 +++++----- ppapi/tests/test_view.cc | 392 ++++++++++++++-------------- ppapi/tests/test_view.h | 102 ++++---- ppapi/thunk/ppb_instance_api.h | 4 +- ppapi/thunk/ppb_mouse_cursor_thunk.cc | 72 ++--- 9 files changed, 550 insertions(+), 550 deletions(-) (limited to 'ppapi') diff --git a/ppapi/api/ppb_mouse_cursor.idl b/ppapi/api/ppb_mouse_cursor.idl index b939016..7d67a8a 100644 --- a/ppapi/api/ppb_mouse_cursor.idl +++ b/ppapi/api/ppb_mouse_cursor.idl @@ -1,106 +1,106 @@ -/* Copyright (c) 2012 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. - */ - -/** - * This file defines the PPB_MouseCursor interface for setting - * the mouse cursor. - */ - -label Chrome { - M19 = 1.0 -}; - -/** - * The PP_MouseCursor_Type enumeration lists the available stock - * cursor types. - */ -[assert_size(4), notypedef] -enum PP_MouseCursor_Type { - PP_MOUSECURSOR_TYPE_CUSTOM = -1, - PP_MOUSECURSOR_TYPE_POINTER = 0, - PP_MOUSECURSOR_TYPE_CROSS = 1, - PP_MOUSECURSOR_TYPE_HAND = 2, - PP_MOUSECURSOR_TYPE_IBEAM = 3, - PP_MOUSECURSOR_TYPE_WAIT = 4, - PP_MOUSECURSOR_TYPE_HELP = 5, - PP_MOUSECURSOR_TYPE_EASTRESIZE = 6, - PP_MOUSECURSOR_TYPE_NORTHRESIZE = 7, - PP_MOUSECURSOR_TYPE_NORTHEASTRESIZE = 8, - PP_MOUSECURSOR_TYPE_NORTHWESTRESIZE = 9, - PP_MOUSECURSOR_TYPE_SOUTHRESIZE = 10, - PP_MOUSECURSOR_TYPE_SOUTHEASTRESIZE = 11, - PP_MOUSECURSOR_TYPE_SOUTHWESTRESIZE = 12, - PP_MOUSECURSOR_TYPE_WESTRESIZE = 13, - PP_MOUSECURSOR_TYPE_NORTHSOUTHRESIZE = 14, - PP_MOUSECURSOR_TYPE_EASTWESTRESIZE = 15, - PP_MOUSECURSOR_TYPE_NORTHEASTSOUTHWESTRESIZE = 16, - PP_MOUSECURSOR_TYPE_NORTHWESTSOUTHEASTRESIZE = 17, - PP_MOUSECURSOR_TYPE_COLUMNRESIZE = 18, - PP_MOUSECURSOR_TYPE_ROWRESIZE = 19, - PP_MOUSECURSOR_TYPE_MIDDLEPANNING = 20, - PP_MOUSECURSOR_TYPE_EASTPANNING = 21, - PP_MOUSECURSOR_TYPE_NORTHPANNING = 22, - PP_MOUSECURSOR_TYPE_NORTHEASTPANNING = 23, - PP_MOUSECURSOR_TYPE_NORTHWESTPANNING = 24, - PP_MOUSECURSOR_TYPE_SOUTHPANNING = 25, - PP_MOUSECURSOR_TYPE_SOUTHEASTPANNING = 26, - PP_MOUSECURSOR_TYPE_SOUTHWESTPANNING = 27, - PP_MOUSECURSOR_TYPE_WESTPANNING = 28, - PP_MOUSECURSOR_TYPE_MOVE = 29, - PP_MOUSECURSOR_TYPE_VERTICALTEXT = 30, - PP_MOUSECURSOR_TYPE_CELL = 31, - PP_MOUSECURSOR_TYPE_CONTEXTMENU = 32, - PP_MOUSECURSOR_TYPE_ALIAS = 33, - PP_MOUSECURSOR_TYPE_PROGRESS = 34, - PP_MOUSECURSOR_TYPE_NODROP = 35, - PP_MOUSECURSOR_TYPE_COPY = 36, - PP_MOUSECURSOR_TYPE_NONE = 37, - PP_MOUSECURSOR_TYPE_NOTALLOWED = 38, - PP_MOUSECURSOR_TYPE_ZOOMIN = 39, - PP_MOUSECURSOR_TYPE_ZOOMOUT = 40, - PP_MOUSECURSOR_TYPE_GRAB = 41, - PP_MOUSECURSOR_TYPE_GRABBING = 42 -}; - -/** - * The PPB_MouseCursor allows setting the mouse cursor. - */ -interface PPB_MouseCursor { - /** - * Sets the given mouse cursor. The mouse cursor will be in effect whenever - * the mouse is over the given instance until it is set again by another - * call. Note that you can hide the mouse cursor by setting it to the - * PP_MOUSECURSOR_TYPE_NONE type. - * - * This function allows setting both system defined mouse cursors and - * custom cursors. To set a system-defined cursor, pass the type you want - * and set the custom image to 0 and the hot spot to NULL. To set a custom - * cursor, set the type to PP_MOUSECURSOR_TYPE_CUSTOM and - * specify your image and hot spot. - * - * @param[in] instance A PP_Instance indentifying the instance - * that the mouse cursor will affect. - * - * @param[in] type A PP_MouseCursor_Type identifying the type of - * mouse cursor to show. - * - * @param[in] image A PPB_ImageData resource identifying the - * custom image to set when the type is - * PP_MOUSECURSOR_TYPE_CUSTOM. The image must be less than 32 - * pixels in each direction and must be of the system's native image format. - * When you are specifying a predefined cursor, this parameter must be 0. - * - * @param[in] hot_spot When setting a custom cursor, this idenfifies the - * pixel position within the given image of the "hot spot" of the cursor. - * When specifying a stock cursor, this parameter is ignored. - * - * @return PP_TRUE on success, or PP_FALSE if the instance or cursor type - * is invalid, or if the image is too large. - */ - PP_Bool SetCursor([in] PP_Instance instance, - [in] PP_MouseCursor_Type type, - [in] PP_Resource image, - [in] PP_Point hot_spot); -}; +/* Copyright (c) 2012 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. + */ + +/** + * This file defines the PPB_MouseCursor interface for setting + * the mouse cursor. + */ + +label Chrome { + M19 = 1.0 +}; + +/** + * The PP_MouseCursor_Type enumeration lists the available stock + * cursor types. + */ +[assert_size(4), notypedef] +enum PP_MouseCursor_Type { + PP_MOUSECURSOR_TYPE_CUSTOM = -1, + PP_MOUSECURSOR_TYPE_POINTER = 0, + PP_MOUSECURSOR_TYPE_CROSS = 1, + PP_MOUSECURSOR_TYPE_HAND = 2, + PP_MOUSECURSOR_TYPE_IBEAM = 3, + PP_MOUSECURSOR_TYPE_WAIT = 4, + PP_MOUSECURSOR_TYPE_HELP = 5, + PP_MOUSECURSOR_TYPE_EASTRESIZE = 6, + PP_MOUSECURSOR_TYPE_NORTHRESIZE = 7, + PP_MOUSECURSOR_TYPE_NORTHEASTRESIZE = 8, + PP_MOUSECURSOR_TYPE_NORTHWESTRESIZE = 9, + PP_MOUSECURSOR_TYPE_SOUTHRESIZE = 10, + PP_MOUSECURSOR_TYPE_SOUTHEASTRESIZE = 11, + PP_MOUSECURSOR_TYPE_SOUTHWESTRESIZE = 12, + PP_MOUSECURSOR_TYPE_WESTRESIZE = 13, + PP_MOUSECURSOR_TYPE_NORTHSOUTHRESIZE = 14, + PP_MOUSECURSOR_TYPE_EASTWESTRESIZE = 15, + PP_MOUSECURSOR_TYPE_NORTHEASTSOUTHWESTRESIZE = 16, + PP_MOUSECURSOR_TYPE_NORTHWESTSOUTHEASTRESIZE = 17, + PP_MOUSECURSOR_TYPE_COLUMNRESIZE = 18, + PP_MOUSECURSOR_TYPE_ROWRESIZE = 19, + PP_MOUSECURSOR_TYPE_MIDDLEPANNING = 20, + PP_MOUSECURSOR_TYPE_EASTPANNING = 21, + PP_MOUSECURSOR_TYPE_NORTHPANNING = 22, + PP_MOUSECURSOR_TYPE_NORTHEASTPANNING = 23, + PP_MOUSECURSOR_TYPE_NORTHWESTPANNING = 24, + PP_MOUSECURSOR_TYPE_SOUTHPANNING = 25, + PP_MOUSECURSOR_TYPE_SOUTHEASTPANNING = 26, + PP_MOUSECURSOR_TYPE_SOUTHWESTPANNING = 27, + PP_MOUSECURSOR_TYPE_WESTPANNING = 28, + PP_MOUSECURSOR_TYPE_MOVE = 29, + PP_MOUSECURSOR_TYPE_VERTICALTEXT = 30, + PP_MOUSECURSOR_TYPE_CELL = 31, + PP_MOUSECURSOR_TYPE_CONTEXTMENU = 32, + PP_MOUSECURSOR_TYPE_ALIAS = 33, + PP_MOUSECURSOR_TYPE_PROGRESS = 34, + PP_MOUSECURSOR_TYPE_NODROP = 35, + PP_MOUSECURSOR_TYPE_COPY = 36, + PP_MOUSECURSOR_TYPE_NONE = 37, + PP_MOUSECURSOR_TYPE_NOTALLOWED = 38, + PP_MOUSECURSOR_TYPE_ZOOMIN = 39, + PP_MOUSECURSOR_TYPE_ZOOMOUT = 40, + PP_MOUSECURSOR_TYPE_GRAB = 41, + PP_MOUSECURSOR_TYPE_GRABBING = 42 +}; + +/** + * The PPB_MouseCursor allows setting the mouse cursor. + */ +interface PPB_MouseCursor { + /** + * Sets the given mouse cursor. The mouse cursor will be in effect whenever + * the mouse is over the given instance until it is set again by another + * call. Note that you can hide the mouse cursor by setting it to the + * PP_MOUSECURSOR_TYPE_NONE type. + * + * This function allows setting both system defined mouse cursors and + * custom cursors. To set a system-defined cursor, pass the type you want + * and set the custom image to 0 and the hot spot to NULL. To set a custom + * cursor, set the type to PP_MOUSECURSOR_TYPE_CUSTOM and + * specify your image and hot spot. + * + * @param[in] instance A PP_Instance indentifying the instance + * that the mouse cursor will affect. + * + * @param[in] type A PP_MouseCursor_Type identifying the type of + * mouse cursor to show. + * + * @param[in] image A PPB_ImageData resource identifying the + * custom image to set when the type is + * PP_MOUSECURSOR_TYPE_CUSTOM. The image must be less than 32 + * pixels in each direction and must be of the system's native image format. + * When you are specifying a predefined cursor, this parameter must be 0. + * + * @param[in] hot_spot When setting a custom cursor, this idenfifies the + * pixel position within the given image of the "hot spot" of the cursor. + * When specifying a stock cursor, this parameter is ignored. + * + * @return PP_TRUE on success, or PP_FALSE if the instance or cursor type + * is invalid, or if the image is too large. + */ + PP_Bool SetCursor([in] PP_Instance instance, + [in] PP_MouseCursor_Type type, + [in] PP_Resource image, + [in] PP_Point hot_spot); +}; diff --git a/ppapi/cpp/mouse_cursor.cc b/ppapi/cpp/mouse_cursor.cc index c5ac20a..acef57a 100644 --- a/ppapi/cpp/mouse_cursor.cc +++ b/ppapi/cpp/mouse_cursor.cc @@ -1,31 +1,31 @@ -// Copyright (c) 2012 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/cpp/mouse_cursor.h" - -#include "ppapi/cpp/module_impl.h" - -namespace pp { - -namespace { - -template <> const char* interface_name() { - return PPB_MOUSECURSOR_INTERFACE_1_0; -} - -} // namespace - -// static -bool MouseCursor::SetCursor(const InstanceHandle& instance, - PP_MouseCursor_Type type, - const ImageData& image, - const Point& hot_spot) { - if (!has_interface()) - return false; - return PP_ToBool(get_interface()->SetCursor( - instance.pp_instance(), type, image.pp_resource(), - &hot_spot.pp_point())); -} - -} // namespace pp +// Copyright (c) 2012 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/cpp/mouse_cursor.h" + +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +template <> const char* interface_name() { + return PPB_MOUSECURSOR_INTERFACE_1_0; +} + +} // namespace + +// static +bool MouseCursor::SetCursor(const InstanceHandle& instance, + PP_MouseCursor_Type type, + const ImageData& image, + const Point& hot_spot) { + if (!has_interface()) + return false; + return PP_ToBool(get_interface()->SetCursor( + instance.pp_instance(), type, image.pp_resource(), + &hot_spot.pp_point())); +} + +} // namespace pp diff --git a/ppapi/cpp/mouse_cursor.h b/ppapi/cpp/mouse_cursor.h index a54084e..ec1374c 100644 --- a/ppapi/cpp/mouse_cursor.h +++ b/ppapi/cpp/mouse_cursor.h @@ -1,56 +1,56 @@ -// Copyright (c) 2012 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 PPAPI_CPP_MOUSE_CURSOR_H_ -#define PPAPI_CPP_MOUSE_CURSOR_H_ - -#include "ppapi/c/ppb_mouse_cursor.h" -#include "ppapi/cpp/image_data.h" -#include "ppapi/cpp/instance_handle.h" -#include "ppapi/cpp/point.h" - -namespace pp { - -class MouseCursor { - public: - /// Sets the given mouse cursor. The mouse cursor will be in effect whenever - /// the mouse is over the given instance until it is set again by another - /// call. Note that you can hide the mouse cursor by setting it to the - /// PP_MOUSECURSOR_TYPE_NONE type. - /// - /// This function allows setting both system defined mouse cursors and - /// custom cursors. To set a system-defined cursor, pass the type you want - /// and set the custom image to a default-constructor ImageData object. - /// To set a custom cursor, set the type to - /// PP_MOUSECURSOR_TYPE_CUSTOM and specify your image and hot - /// spot. - /// - /// @param[in] instance A handle indentifying the instance that the mouse - /// cursor will affect. - /// - /// @param[in] type A PP_MouseCursor_Type identifying the type - /// of mouse cursor to show. See ppapi/c/ppb_mouse_cursor.h. - /// - /// @param[in] image A ImageData object identifying the - /// custom image to set when the type is - /// PP_MOUSECURSOR_TYPE_CUSTOM. The image must be less than 32 - /// pixels in each direction and must be of the system's native image format. - /// When you are specifying a predefined cursor, this parameter should be a - /// default-constructed ImageData. - /// - /// @param[in] hot_spot When setting a custom cursor, this idenfifies the - /// pixel position within the given image of the "hot spot" of the cursor. - /// When specifying a stock cursor, this parameter is ignored. - /// - /// @return true on success, or false if the instance or cursor type - /// was invalid or if the image was too large. - static bool SetCursor(const InstanceHandle& instance, - PP_MouseCursor_Type type, - const ImageData& image = ImageData(), - const Point& hot_spot = Point(0, 0)); -}; - -} // namespace pp - -#endif // PPAPI_CPP_MOUSE_CURSOR_H_ +// Copyright (c) 2012 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 PPAPI_CPP_MOUSE_CURSOR_H_ +#define PPAPI_CPP_MOUSE_CURSOR_H_ + +#include "ppapi/c/ppb_mouse_cursor.h" +#include "ppapi/cpp/image_data.h" +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/point.h" + +namespace pp { + +class MouseCursor { + public: + /// Sets the given mouse cursor. The mouse cursor will be in effect whenever + /// the mouse is over the given instance until it is set again by another + /// call. Note that you can hide the mouse cursor by setting it to the + /// PP_MOUSECURSOR_TYPE_NONE type. + /// + /// This function allows setting both system defined mouse cursors and + /// custom cursors. To set a system-defined cursor, pass the type you want + /// and set the custom image to a default-constructor ImageData object. + /// To set a custom cursor, set the type to + /// PP_MOUSECURSOR_TYPE_CUSTOM and specify your image and hot + /// spot. + /// + /// @param[in] instance A handle indentifying the instance that the mouse + /// cursor will affect. + /// + /// @param[in] type A PP_MouseCursor_Type identifying the type + /// of mouse cursor to show. See ppapi/c/ppb_mouse_cursor.h. + /// + /// @param[in] image A ImageData object identifying the + /// custom image to set when the type is + /// PP_MOUSECURSOR_TYPE_CUSTOM. The image must be less than 32 + /// pixels in each direction and must be of the system's native image format. + /// When you are specifying a predefined cursor, this parameter should be a + /// default-constructed ImageData. + /// + /// @param[in] hot_spot When setting a custom cursor, this idenfifies the + /// pixel position within the given image of the "hot spot" of the cursor. + /// When specifying a stock cursor, this parameter is ignored. + /// + /// @return true on success, or false if the instance or cursor type + /// was invalid or if the image was too large. + static bool SetCursor(const InstanceHandle& instance, + PP_MouseCursor_Type type, + const ImageData& image = ImageData(), + const Point& hot_spot = Point(0, 0)); +}; + +} // namespace pp + +#endif // PPAPI_CPP_MOUSE_CURSOR_H_ diff --git a/ppapi/examples/mouse_cursor/mouse_cursor.cc b/ppapi/examples/mouse_cursor/mouse_cursor.cc index 0c8b10b..8a70b15 100644 --- a/ppapi/examples/mouse_cursor/mouse_cursor.cc +++ b/ppapi/examples/mouse_cursor/mouse_cursor.cc @@ -32,11 +32,11 @@ class MyInstance : public pp::Instance { virtual ~MyInstance() { } - virtual void DidChangeView(const pp::View& view) { - width_ = view.GetRect().width(); - height_ = view.GetRect().height(); - } - + virtual void DidChangeView(const pp::View& view) { + width_ = view.GetRect().width(); + height_ = view.GetRect().height(); + } + virtual bool HandleInputEvent(const pp::InputEvent& event) { switch (event.GetType()) { case PP_INPUTEVENT_TYPE_MOUSEDOWN: diff --git a/ppapi/tests/test_page.css b/ppapi/tests/test_page.css index 7cce1ff..de76c41 100644 --- a/ppapi/tests/test_page.css +++ b/ppapi/tests/test_page.css @@ -1,67 +1,67 @@ -body { - font-family:Verdana,Arial,sans-serif; - padding: 0; - margin: 0; -} - -p.frame-container { - margin: 0; - margin-top: 1em ! important; - margin-bottom: 1em ! important; - padding: 0; -} - -p.frame-container > h2 { - font-size: 1.1em; - margin: 0; - margin-left: 10% ! important; - padding: 0; -} - -p.frame-container > iframe { - margin: 0; - padding: 0; - border: none; - width: 100%; - height: 30%; -} - -#console { - border:1px solid black; - padding:4px; - background-color:#EEE; - margin-left:10%; - margin-right:10%; -} - -#container { - height: 16px; -} - -#container > object { - width: 100%; - height: 100%; -} - -.test_line { -} - -.test_name { -} - -.pass { - font-weight:bold; - color:#080; -} - -.fail { - font-weight:bold; - color:#800; -} - -.err_msg { -} - -.load_msg { - font-style:italic; -} +body { + font-family:Verdana,Arial,sans-serif; + padding: 0; + margin: 0; +} + +p.frame-container { + margin: 0; + margin-top: 1em ! important; + margin-bottom: 1em ! important; + padding: 0; +} + +p.frame-container > h2 { + font-size: 1.1em; + margin: 0; + margin-left: 10% ! important; + padding: 0; +} + +p.frame-container > iframe { + margin: 0; + padding: 0; + border: none; + width: 100%; + height: 30%; +} + +#console { + border:1px solid black; + padding:4px; + background-color:#EEE; + margin-left:10%; + margin-right:10%; +} + +#container { + height: 16px; +} + +#container > object { + width: 100%; + height: 100%; +} + +.test_line { +} + +.test_name { +} + +.pass { + font-weight:bold; + color:#080; +} + +.fail { + font-weight:bold; + color:#800; +} + +.err_msg { +} + +.load_msg { + font-style:italic; +} diff --git a/ppapi/tests/test_view.cc b/ppapi/tests/test_view.cc index 6a8e748..44b0225 100644 --- a/ppapi/tests/test_view.cc +++ b/ppapi/tests/test_view.cc @@ -1,196 +1,196 @@ -// 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_view.h" - -#include - -#include "ppapi/c/pp_time.h" -#include "ppapi/c/dev/ppb_testing_dev.h" -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/tests/testing_instance.h" - -REGISTER_TEST_CASE(View); - -// When waiting for view changed events, wait no longer than this. -static int kViewChangeTimeoutSec = 5; - -TestView::TestView(TestingInstance* instance) - : TestCase(instance), - post_quit_on_view_changed_(false) { -} - -void TestView::DidChangeView(const pp::View& view) { - last_view_ = view; - page_visibility_log_.push_back(view.IsPageVisible()); - - if (post_quit_on_view_changed_) { - post_quit_on_view_changed_ = false; - testing_interface_->QuitMessageLoop(instance_->pp_instance()); - } -} - -bool TestView::Init() { - return CheckTestingInterface(); -} - -void TestView::RunTests(const std::string& filter) { - RUN_TEST(CreatedVisible, filter); - RUN_TEST(CreatedInvisible, filter); - RUN_TEST(PageHideShow, filter); - RUN_TEST(SizeChange, filter); - RUN_TEST(ClipChange, filter); -} - -bool TestView::WaitUntilViewChanged() { - // Schedule a callback so this step times out if we don't get a ViewChanged - // in a reasonable amount of time. - pp::CompletionCallbackFactory factory(this); - pp::CompletionCallback timeout = - factory.NewCallback(&TestView::QuitMessageLoop); - pp::Module::Get()->core()->CallOnMainThread( - kViewChangeTimeoutSec * 1000, timeout); - - size_t old_page_visibility_change_count = page_visibility_log_.size(); - - // Run a nested message loop. It will exit either on ViewChanged or if the - // timeout happens. - post_quit_on_view_changed_ = true; - testing_interface_->RunMessageLoop(instance_->pp_instance()); - post_quit_on_view_changed_ = false; - - // We know we got a view changed event if something was appended to the log. - return page_visibility_log_.size() > old_page_visibility_change_count; -} - -void TestView::QuitMessageLoop(int32_t result) { - testing_interface_->QuitMessageLoop(instance_->pp_instance()); -} - -std::string TestView::TestCreatedVisible() { - ASSERT_FALSE(page_visibility_log_.empty()); - ASSERT_TRUE(page_visibility_log_[0]); - PASS(); -} - -std::string TestView::TestCreatedInvisible() { - ASSERT_FALSE(page_visibility_log_.empty()); - - if (page_visibility_log_[0]) { - // Add more error message since this test has some extra requirements. - instance_->AppendError("Initial page is set to visible. NOTE: " - "This test must be run in a background tab. " - "Either run in the UI test which does this, or you can middle-click " - "on the test link to run manually."); - } - ASSERT_FALSE(page_visibility_log_[0]); - PASS(); -} - -std::string TestView::TestPageHideShow() { - // Initial state should be visible. - ASSERT_FALSE(page_visibility_log_.empty()); - ASSERT_TRUE(page_visibility_log_[0]); - - // Now that we're alive, tell the test knows it can change our visibility. - instance_->ReportProgress("TestPageHideShow:Created"); - - // Wait until we get a hide event, being careful to handle spurious - // notifications of ViewChanged. - PP_Time begin_time = pp::Module::Get()->core()->GetTime(); - while (WaitUntilViewChanged() && - page_visibility_log_[page_visibility_log_.size() - 1] && - pp::Module::Get()->core()->GetTime() - begin_time < - kViewChangeTimeoutSec) { - } - if (page_visibility_log_[page_visibility_log_.size() - 1]) { - // Didn't get a view changed event that changed visibility (though there - // may have been some that didn't change visibility). - // Add more error message since this test has some extra requirements. - return "Didn't receive a hide event in timeout. NOTE: " - "This test requires tab visibility to change and won't pass if you " - "just run it in a browser. Normally the UI test should handle " - "this. You can also run manually by waiting 2 secs, creating a new " - "tab, waiting 2 more secs, and closing the new tab."; - } - - // Tell the test so it can show us again. - instance_->ReportProgress("TestPageHideShow:Hidden"); - - // Wait until we get a show event. - begin_time = pp::Module::Get()->core()->GetTime(); - while (WaitUntilViewChanged() && - !page_visibility_log_[page_visibility_log_.size() - 1] && - pp::Module::Get()->core()->GetTime() - begin_time < - kViewChangeTimeoutSec) { - } - ASSERT_TRUE(page_visibility_log_[page_visibility_log_.size() - 1]); - - PASS(); -} - -std::string TestView::TestSizeChange() { - pp::Rect original_rect = last_view_.GetRect(); - - pp::Rect desired_rect = original_rect; - desired_rect.set_width(original_rect.width() + 10); - desired_rect.set_height(original_rect.height() + 12); - - std::ostringstream script_stream; - script_stream << "var plugin = document.getElementById('plugin');"; - script_stream << "plugin.setAttribute('width', " - << desired_rect.width() << ");"; - script_stream << "plugin.setAttribute('height', " - << desired_rect.height() << ");"; - - instance_->EvalScript(script_stream.str()); - - PP_Time begin_time = pp::Module::Get()->core()->GetTime(); - while (WaitUntilViewChanged() && last_view_.GetRect() != desired_rect && - pp::Module::Get()->core()->GetTime() - begin_time < - kViewChangeTimeoutSec) { - } - ASSERT_TRUE(last_view_.GetRect() == desired_rect); - - PASS(); -} - -std::string TestView::TestClipChange() { - pp::Rect original_rect = last_view_.GetRect(); - - // Original clip should be the full frame. - pp::Rect original_clip = last_view_.GetClipRect(); - ASSERT_TRUE(original_clip.x() == 0); - ASSERT_TRUE(original_clip.y() == 0); - ASSERT_TRUE(original_clip.width() == original_rect.width()); - ASSERT_TRUE(original_clip.height() == original_rect.height()); - - int clip_amount = original_rect.height() / 2; - - // It might be nice to set the position to be absolute and set the location, - // but this will cause WebKit to actually tear down the plugin and recreate - // it. So instead we add a big div to cause the document to be scrollable, - // and scroll it down. - std::ostringstream script_stream; - script_stream - << "var big = document.createElement('div');" - << "big.setAttribute('style', 'position:absolute; left:100px; " - "top:0px; width:1px; height:5000px;');" - << "document.body.appendChild(big);" - << "window.scrollBy(0, " << original_rect.y() + clip_amount << ");"; - - instance_->EvalScript(script_stream.str()); - - pp::Rect desired_clip = original_clip; - desired_clip.set_y(clip_amount); - desired_clip.set_height(desired_clip.height() - desired_clip.y()); - - PP_Time begin_time = pp::Module::Get()->core()->GetTime(); - while (WaitUntilViewChanged() && last_view_.GetClipRect() != desired_clip && - pp::Module::Get()->core()->GetTime() - begin_time < - kViewChangeTimeoutSec) { - } - ASSERT_TRUE(last_view_.GetClipRect() == desired_clip); - PASS(); -} +// 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_view.h" + +#include + +#include "ppapi/c/pp_time.h" +#include "ppapi/c/dev/ppb_testing_dev.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/tests/testing_instance.h" + +REGISTER_TEST_CASE(View); + +// When waiting for view changed events, wait no longer than this. +static int kViewChangeTimeoutSec = 5; + +TestView::TestView(TestingInstance* instance) + : TestCase(instance), + post_quit_on_view_changed_(false) { +} + +void TestView::DidChangeView(const pp::View& view) { + last_view_ = view; + page_visibility_log_.push_back(view.IsPageVisible()); + + if (post_quit_on_view_changed_) { + post_quit_on_view_changed_ = false; + testing_interface_->QuitMessageLoop(instance_->pp_instance()); + } +} + +bool TestView::Init() { + return CheckTestingInterface(); +} + +void TestView::RunTests(const std::string& filter) { + RUN_TEST(CreatedVisible, filter); + RUN_TEST(CreatedInvisible, filter); + RUN_TEST(PageHideShow, filter); + RUN_TEST(SizeChange, filter); + RUN_TEST(ClipChange, filter); +} + +bool TestView::WaitUntilViewChanged() { + // Schedule a callback so this step times out if we don't get a ViewChanged + // in a reasonable amount of time. + pp::CompletionCallbackFactory factory(this); + pp::CompletionCallback timeout = + factory.NewCallback(&TestView::QuitMessageLoop); + pp::Module::Get()->core()->CallOnMainThread( + kViewChangeTimeoutSec * 1000, timeout); + + size_t old_page_visibility_change_count = page_visibility_log_.size(); + + // Run a nested message loop. It will exit either on ViewChanged or if the + // timeout happens. + post_quit_on_view_changed_ = true; + testing_interface_->RunMessageLoop(instance_->pp_instance()); + post_quit_on_view_changed_ = false; + + // We know we got a view changed event if something was appended to the log. + return page_visibility_log_.size() > old_page_visibility_change_count; +} + +void TestView::QuitMessageLoop(int32_t result) { + testing_interface_->QuitMessageLoop(instance_->pp_instance()); +} + +std::string TestView::TestCreatedVisible() { + ASSERT_FALSE(page_visibility_log_.empty()); + ASSERT_TRUE(page_visibility_log_[0]); + PASS(); +} + +std::string TestView::TestCreatedInvisible() { + ASSERT_FALSE(page_visibility_log_.empty()); + + if (page_visibility_log_[0]) { + // Add more error message since this test has some extra requirements. + instance_->AppendError("Initial page is set to visible. NOTE: " + "This test must be run in a background tab. " + "Either run in the UI test which does this, or you can middle-click " + "on the test link to run manually."); + } + ASSERT_FALSE(page_visibility_log_[0]); + PASS(); +} + +std::string TestView::TestPageHideShow() { + // Initial state should be visible. + ASSERT_FALSE(page_visibility_log_.empty()); + ASSERT_TRUE(page_visibility_log_[0]); + + // Now that we're alive, tell the test knows it can change our visibility. + instance_->ReportProgress("TestPageHideShow:Created"); + + // Wait until we get a hide event, being careful to handle spurious + // notifications of ViewChanged. + PP_Time begin_time = pp::Module::Get()->core()->GetTime(); + while (WaitUntilViewChanged() && + page_visibility_log_[page_visibility_log_.size() - 1] && + pp::Module::Get()->core()->GetTime() - begin_time < + kViewChangeTimeoutSec) { + } + if (page_visibility_log_[page_visibility_log_.size() - 1]) { + // Didn't get a view changed event that changed visibility (though there + // may have been some that didn't change visibility). + // Add more error message since this test has some extra requirements. + return "Didn't receive a hide event in timeout. NOTE: " + "This test requires tab visibility to change and won't pass if you " + "just run it in a browser. Normally the UI test should handle " + "this. You can also run manually by waiting 2 secs, creating a new " + "tab, waiting 2 more secs, and closing the new tab."; + } + + // Tell the test so it can show us again. + instance_->ReportProgress("TestPageHideShow:Hidden"); + + // Wait until we get a show event. + begin_time = pp::Module::Get()->core()->GetTime(); + while (WaitUntilViewChanged() && + !page_visibility_log_[page_visibility_log_.size() - 1] && + pp::Module::Get()->core()->GetTime() - begin_time < + kViewChangeTimeoutSec) { + } + ASSERT_TRUE(page_visibility_log_[page_visibility_log_.size() - 1]); + + PASS(); +} + +std::string TestView::TestSizeChange() { + pp::Rect original_rect = last_view_.GetRect(); + + pp::Rect desired_rect = original_rect; + desired_rect.set_width(original_rect.width() + 10); + desired_rect.set_height(original_rect.height() + 12); + + std::ostringstream script_stream; + script_stream << "var plugin = document.getElementById('plugin');"; + script_stream << "plugin.setAttribute('width', " + << desired_rect.width() << ");"; + script_stream << "plugin.setAttribute('height', " + << desired_rect.height() << ");"; + + instance_->EvalScript(script_stream.str()); + + PP_Time begin_time = pp::Module::Get()->core()->GetTime(); + while (WaitUntilViewChanged() && last_view_.GetRect() != desired_rect && + pp::Module::Get()->core()->GetTime() - begin_time < + kViewChangeTimeoutSec) { + } + ASSERT_TRUE(last_view_.GetRect() == desired_rect); + + PASS(); +} + +std::string TestView::TestClipChange() { + pp::Rect original_rect = last_view_.GetRect(); + + // Original clip should be the full frame. + pp::Rect original_clip = last_view_.GetClipRect(); + ASSERT_TRUE(original_clip.x() == 0); + ASSERT_TRUE(original_clip.y() == 0); + ASSERT_TRUE(original_clip.width() == original_rect.width()); + ASSERT_TRUE(original_clip.height() == original_rect.height()); + + int clip_amount = original_rect.height() / 2; + + // It might be nice to set the position to be absolute and set the location, + // but this will cause WebKit to actually tear down the plugin and recreate + // it. So instead we add a big div to cause the document to be scrollable, + // and scroll it down. + std::ostringstream script_stream; + script_stream + << "var big = document.createElement('div');" + << "big.setAttribute('style', 'position:absolute; left:100px; " + "top:0px; width:1px; height:5000px;');" + << "document.body.appendChild(big);" + << "window.scrollBy(0, " << original_rect.y() + clip_amount << ");"; + + instance_->EvalScript(script_stream.str()); + + pp::Rect desired_clip = original_clip; + desired_clip.set_y(clip_amount); + desired_clip.set_height(desired_clip.height() - desired_clip.y()); + + PP_Time begin_time = pp::Module::Get()->core()->GetTime(); + while (WaitUntilViewChanged() && last_view_.GetClipRect() != desired_clip && + pp::Module::Get()->core()->GetTime() - begin_time < + kViewChangeTimeoutSec) { + } + ASSERT_TRUE(last_view_.GetClipRect() == desired_clip); + PASS(); +} diff --git a/ppapi/tests/test_view.h b/ppapi/tests/test_view.h index ff8b70a..140d4cf 100644 --- a/ppapi/tests/test_view.h +++ b/ppapi/tests/test_view.h @@ -1,51 +1,51 @@ -// 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 PPAPI_TEST_TEST_VIEW_H_ -#define PPAPI_TEST_TEST_VIEW_H_ - -#include "ppapi/cpp/view.h" -#include "ppapi/tests/test_case.h" - -class TestView : public TestCase { - public: - TestView(TestingInstance* instance); - - virtual void DidChangeView(const pp::View& view); - - // TestCase implementation. - virtual bool Init(); - virtual void RunTests(const std::string& test_filter); - - private: - // Waits until we get a view changed event. Note that the browser may give - // us any number of view changed events, so tests that use this should - // expect that there may be spurious events and handle them accordingly. - // Note also that view changed sequencing can change between different - // versions of WebKit. - // - // Returns true if we got a view changed, false if it timed out. - bool WaitUntilViewChanged(); - - void QuitMessageLoop(int32_t result); - - std::string TestCreatedVisible(); - std::string TestCreatedInvisible(); - std::string TestPageHideShow(); - std::string TestSizeChange(); - std::string TestClipChange(); - - pp::View last_view_; - - // DidChangeView stores the page visibility in this vector on each - // invocation so tests can check it. - std::vector page_visibility_log_; - - // Set to true to request that the next invocation of DidChangeView should - // post a quit to the message loop. DidChangeView will also reset the flag so - // this will only happen once. - bool post_quit_on_view_changed_; -}; - -#endif // PPAPI_TEST_TEST_VIEW_H_ +// 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 PPAPI_TEST_TEST_VIEW_H_ +#define PPAPI_TEST_TEST_VIEW_H_ + +#include "ppapi/cpp/view.h" +#include "ppapi/tests/test_case.h" + +class TestView : public TestCase { + public: + TestView(TestingInstance* instance); + + virtual void DidChangeView(const pp::View& view); + + // TestCase implementation. + virtual bool Init(); + virtual void RunTests(const std::string& test_filter); + + private: + // Waits until we get a view changed event. Note that the browser may give + // us any number of view changed events, so tests that use this should + // expect that there may be spurious events and handle them accordingly. + // Note also that view changed sequencing can change between different + // versions of WebKit. + // + // Returns true if we got a view changed, false if it timed out. + bool WaitUntilViewChanged(); + + void QuitMessageLoop(int32_t result); + + std::string TestCreatedVisible(); + std::string TestCreatedInvisible(); + std::string TestPageHideShow(); + std::string TestSizeChange(); + std::string TestClipChange(); + + pp::View last_view_; + + // DidChangeView stores the page visibility in this vector on each + // invocation so tests can check it. + std::vector page_visibility_log_; + + // Set to true to request that the next invocation of DidChangeView should + // post a quit to the message loop. DidChangeView will also reset the flag so + // this will only happen once. + bool post_quit_on_view_changed_; +}; + +#endif // PPAPI_TEST_TEST_VIEW_H_ diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h index 58f119f..7ce4e78 100644 --- a/ppapi/thunk/ppb_instance_api.h +++ b/ppapi/thunk/ppb_instance_api.h @@ -103,8 +103,8 @@ class PPB_Instance_FunctionAPI { // Mouse cursor. virtual PP_Bool SetCursor(PP_Instance instance, PP_MouseCursor_Type type, - PP_Resource image, - const PP_Point* hot_spot) = 0; + PP_Resource image, + const PP_Point* hot_spot) = 0; // MouseLock. virtual int32_t LockMouse(PP_Instance instance, diff --git a/ppapi/thunk/ppb_mouse_cursor_thunk.cc b/ppapi/thunk/ppb_mouse_cursor_thunk.cc index f2c6f41..1bf9f42 100644 --- a/ppapi/thunk/ppb_mouse_cursor_thunk.cc +++ b/ppapi/thunk/ppb_mouse_cursor_thunk.cc @@ -1,36 +1,36 @@ -// Copyright (c) 2012 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/c/ppb_mouse_cursor.h" -#include "ppapi/thunk/thunk.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppb_instance_api.h" - -namespace ppapi { -namespace thunk { - -namespace { - -PP_Bool SetCursor(PP_Instance instance, - PP_MouseCursor_Type type, - PP_Resource image, - const PP_Point* hot_spot) { - EnterInstance enter(instance); - if (enter.failed()) - return PP_FALSE; - return enter.functions()->SetCursor(instance, type, image, hot_spot); -} - -const PPB_MouseCursor_1_0 g_ppb_mouse_cursor_thunk = { - &SetCursor -}; - -} // namespace - -const PPB_MouseCursor_1_0* GetPPB_MouseCursor_1_0_Thunk() { - return &g_ppb_mouse_cursor_thunk; -} - -} // namespace thunk -} // namespace ppapi +// Copyright (c) 2012 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/c/ppb_mouse_cursor.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_instance_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Bool SetCursor(PP_Instance instance, + PP_MouseCursor_Type type, + PP_Resource image, + const PP_Point* hot_spot) { + EnterInstance enter(instance); + if (enter.failed()) + return PP_FALSE; + return enter.functions()->SetCursor(instance, type, image, hot_spot); +} + +const PPB_MouseCursor_1_0 g_ppb_mouse_cursor_thunk = { + &SetCursor +}; + +} // namespace + +const PPB_MouseCursor_1_0* GetPPB_MouseCursor_1_0_Thunk() { + return &g_ppb_mouse_cursor_thunk; +} + +} // namespace thunk +} // namespace ppapi -- cgit v1.1