Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(712)

Side by Side Diff: ppapi/tests/test_mouse_lock.cc

Issue 10699045: Fix PPB_MouseLock.LockMouse crash and add tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_mouse_lock.h ('k') | ppapi/thunk/enter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ppapi/tests/test_mouse_lock.h"
6
7 #include "ppapi/cpp/input_event.h"
8 #include "ppapi/cpp/view.h"
9 #include "ppapi/tests/testing_instance.h"
10
11 REGISTER_TEST_CASE(MouseLock);
12
13 TestMouseLock::TestMouseLock(TestingInstance* instance)
14 : TestCase(instance),
15 MouseLock(instance),
16 nested_event_(instance->pp_instance()) {
17 }
18
19 TestMouseLock::~TestMouseLock() {
20 }
21
22 bool TestMouseLock::Init() {
23 return CheckTestingInterface();
24 }
25
26 void TestMouseLock::RunTests(const std::string& filter) {
27 RUN_TEST(SucceedWhenAllowed, filter);
28 RUN_TEST(FailWhenBlocked, filter);
29 }
30
31 void TestMouseLock::DidChangeView(const pp::View& view) {
32 position_ = view.GetRect();
33 }
34
35 void TestMouseLock::MouseLockLost() {
36 nested_event_.Signal();
37 }
38
39 std::string TestMouseLock::TestSucceedWhenAllowed() {
40 // Content settings are configured to allow mouse lock for any site.
41 // Please see chrome/test/ppapi/ppapi_interactive_browsertest.cc.
42 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
43 SimulateUserGesture();
44 callback.WaitForResult(LockMouse(callback));
45 ASSERT_EQ(PP_OK, callback.result());
46
47 UnlockMouse();
48 // Wait for the MouseLockLost() call.
49 nested_event_.Wait();
50
51 PASS();
52 }
53
54 std::string TestMouseLock::TestFailWhenBlocked() {
55 // Content settings are configured to block mouse lock for any site.
56 // Please see chrome/test/ppapi/ppapi_interactive_browsertest.cc.
57 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
58 SimulateUserGesture();
59 callback.WaitForResult(LockMouse(callback));
60 ASSERT_NE(PP_OK, callback.result());
61
62 PASS();
63 }
64
65 void TestMouseLock::SimulateUserGesture() {
66 pp::Point mouse_movement;
67 pp::MouseInputEvent input_event(
68 instance_,
69 PP_INPUTEVENT_TYPE_MOUSEDOWN,
70 0, // time_stamp
71 0, // modifiers
72 PP_INPUTEVENT_MOUSEBUTTON_LEFT,
73 position_.CenterPoint(),
74 1, // click_count
75 mouse_movement);
76
77 testing_interface_->SimulateInputEvent(instance_->pp_instance(),
78 input_event.pp_resource());
79 }
OLDNEW
« no previous file with comments | « ppapi/tests/test_mouse_lock.h ('k') | ppapi/thunk/enter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698