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

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

Issue 2419413002: Deleted CONTENT_SETTINGS_TYPE_FULLSCREEN and MOUSELOCK. (Closed)
Patch Set: Fix more things. Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/tests/test_mouse_lock.h" 5 #include "ppapi/tests/test_mouse_lock.h"
6 6
7 #include "ppapi/cpp/input_event.h" 7 #include "ppapi/cpp/input_event.h"
8 #include "ppapi/cpp/view.h" 8 #include "ppapi/cpp/view.h"
9 #include "ppapi/tests/testing_instance.h" 9 #include "ppapi/tests/testing_instance.h"
10 10
11 REGISTER_TEST_CASE(MouseLock); 11 REGISTER_TEST_CASE(MouseLock);
12 12
13 TestMouseLock::TestMouseLock(TestingInstance* instance) 13 TestMouseLock::TestMouseLock(TestingInstance* instance)
14 : TestCase(instance), 14 : TestCase(instance),
15 MouseLock(instance), 15 MouseLock(instance),
16 nested_event_(instance->pp_instance()) { 16 nested_event_(instance->pp_instance()) {
17 } 17 }
18 18
19 TestMouseLock::~TestMouseLock() { 19 TestMouseLock::~TestMouseLock() {
20 } 20 }
21 21
22 bool TestMouseLock::Init() { 22 bool TestMouseLock::Init() {
23 return CheckTestingInterface(); 23 return CheckTestingInterface();
24 } 24 }
25 25
26 void TestMouseLock::RunTests(const std::string& filter) { 26 void TestMouseLock::RunTests(const std::string& filter) {
27 RUN_TEST(SucceedWhenAllowed, filter); 27 RUN_TEST(SucceedWhenAllowed, filter);
28 RUN_TEST(FailWhenBlocked, filter);
29 } 28 }
30 29
31 void TestMouseLock::DidChangeView(const pp::View& view) { 30 void TestMouseLock::DidChangeView(const pp::View& view) {
32 position_ = view.GetRect(); 31 position_ = view.GetRect();
33 } 32 }
34 33
35 void TestMouseLock::MouseLockLost() { 34 void TestMouseLock::MouseLockLost() {
36 nested_event_.Signal(); 35 nested_event_.Signal();
37 } 36 }
38 37
39 std::string TestMouseLock::TestSucceedWhenAllowed() { 38 std::string TestMouseLock::TestSucceedWhenAllowed() {
40 // Content settings are configured to allow mouse lock for any site. 39 // Content settings are configured to allow mouse lock for any site.
41 // Please see chrome/test/ppapi/ppapi_interactive_browsertest.cc. 40 // Please see chrome/test/ppapi/ppapi_interactive_browsertest.cc.
42 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); 41 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
43 SimulateUserGesture(); 42 SimulateUserGesture();
44 callback.WaitForResult(LockMouse(callback.GetCallback())); 43 callback.WaitForResult(LockMouse(callback.GetCallback()));
45 ASSERT_EQ(PP_OK, callback.result()); 44 ASSERT_EQ(PP_OK, callback.result());
46 45
47 UnlockMouse(); 46 UnlockMouse();
48 // Wait for the MouseLockLost() call. 47 // Wait for the MouseLockLost() call.
49 nested_event_.Wait(); 48 nested_event_.Wait();
50 49
51 PASS(); 50 PASS();
52 } 51 }
53 52
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.GetCallback()));
60 ASSERT_NE(PP_OK, callback.result());
61
62 PASS();
63 }
64
65 void TestMouseLock::SimulateUserGesture() { 53 void TestMouseLock::SimulateUserGesture() {
66 pp::Point mouse_movement; 54 pp::Point mouse_movement;
67 pp::MouseInputEvent input_event( 55 pp::MouseInputEvent input_event(
68 instance_, 56 instance_,
69 PP_INPUTEVENT_TYPE_MOUSEDOWN, 57 PP_INPUTEVENT_TYPE_MOUSEDOWN,
70 0, // time_stamp 58 0, // time_stamp
71 0, // modifiers 59 0, // modifiers
72 PP_INPUTEVENT_MOUSEBUTTON_LEFT, 60 PP_INPUTEVENT_MOUSEBUTTON_LEFT,
73 position_.CenterPoint(), 61 position_.CenterPoint(),
74 1, // click_count 62 1, // click_count
75 mouse_movement); 63 mouse_movement);
76 64
77 testing_interface_->SimulateInputEvent(instance_->pp_instance(), 65 testing_interface_->SimulateInputEvent(instance_->pp_instance(),
78 input_event.pp_resource()); 66 input_event.pp_resource());
79 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698