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

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')
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 TestCompletionCallback callback(instance_->pp_instance());
41 SimulateUserGesture();
42 int32_t rv = LockMouse(callback);
43 if (rv == PP_OK_COMPLETIONPENDING)
44 rv = callback.WaitForResult();
45 if (rv != PP_OK)
46 return ReportError("MouseLock::LockMouse", rv);
47
48 UnlockMouse();
49 // Wait for the MouseLockLost() call.
50 nested_event_.Wait();
51
52 PASS();
53 }
54
55 std::string TestMouseLock::TestFailWhenBlocked() {
56 TestCompletionCallback callback(instance_->pp_instance());
57 SimulateUserGesture();
58 int32_t rv = LockMouse(callback);
59 if (rv == PP_OK_COMPLETIONPENDING)
scheib 2012/06/30 03:18:58 How does this test differ from TestSucceedWhenAllo
yzshen1 2012/06/30 21:39:14 Done. Thanks!
60 rv = callback.WaitForResult();
61 ASSERT_NE(PP_OK, rv);
62
63 PASS();
64 }
65
66 void TestMouseLock::SimulateUserGesture() {
67 pp::Point mouse_movement;
68 pp::MouseInputEvent input_event(
69 instance_,
70 PP_INPUTEVENT_TYPE_MOUSEDOWN,
71 0, // time_stamp
72 0, // modifiers
73 PP_INPUTEVENT_MOUSEBUTTON_LEFT,
74 position_.CenterPoint(),
75 1, // click_count
76 mouse_movement);
77
78 testing_interface_->SimulateInputEvent(instance_->pp_instance(),
79 input_event.pp_resource());
80 }
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