OLD | NEW |
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_flash_fullscreen.h" | 5 #include "ppapi/tests/test_flash_fullscreen.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 clip.size() == screen_size); | 33 clip.size() == screen_size); |
34 } | 34 } |
35 | 35 |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 TestFlashFullscreen::TestFlashFullscreen(TestingInstance* instance) | 38 TestFlashFullscreen::TestFlashFullscreen(TestingInstance* instance) |
39 : TestCase(instance), | 39 : TestCase(instance), |
40 screen_mode_(instance), | 40 screen_mode_(instance), |
41 fullscreen_pending_(false), | 41 fullscreen_pending_(false), |
42 normal_pending_(false), | 42 normal_pending_(false), |
43 fullscreen_callback_(instance->pp_instance()), | 43 fullscreen_event_(instance->pp_instance()), |
44 normal_callback_(instance->pp_instance()) { | 44 normal_event_(instance->pp_instance()) { |
45 screen_mode_.GetScreenSize(&screen_size_); | 45 screen_mode_.GetScreenSize(&screen_size_); |
46 } | 46 } |
47 | 47 |
48 bool TestFlashFullscreen::Init() { | 48 bool TestFlashFullscreen::Init() { |
49 return CheckTestingInterface(); | 49 return CheckTestingInterface(); |
50 } | 50 } |
51 | 51 |
52 void TestFlashFullscreen::RunTests(const std::string& filter) { | 52 void TestFlashFullscreen::RunTests(const std::string& filter) { |
53 RUN_TEST(GetScreenSize, filter); | 53 RUN_TEST(GetScreenSize, filter); |
54 RUN_TEST(NormalToFullscreenToNormal, filter); | 54 RUN_TEST(NormalToFullscreenToNormal, filter); |
(...skipping 24 matching lines...) Expand all Loading... |
79 // The out-of-process proxy is asynchronous, so testing for the following | 79 // The out-of-process proxy is asynchronous, so testing for the following |
80 // conditions is flaky and can only be done reliably in-process. | 80 // conditions is flaky and can only be done reliably in-process. |
81 if (!testing_interface_->IsOutOfProcess()) { | 81 if (!testing_interface_->IsOutOfProcess()) { |
82 if (instance_->BindGraphics(graphics2d_fullscreen)) | 82 if (instance_->BindGraphics(graphics2d_fullscreen)) |
83 return ReportError("BindGraphics() in fullscreen transition", true); | 83 return ReportError("BindGraphics() in fullscreen transition", true); |
84 if (screen_mode_.IsFullscreen()) | 84 if (screen_mode_.IsFullscreen()) |
85 return ReportError("IsFullscreen() in fullscreen transtion", true); | 85 return ReportError("IsFullscreen() in fullscreen transtion", true); |
86 } | 86 } |
87 | 87 |
88 // DidChangeView() will call the callback once in fullscreen mode. | 88 // DidChangeView() will call the callback once in fullscreen mode. |
89 fullscreen_callback_.WaitForResult(); | 89 fullscreen_event_.Wait(); |
90 if (fullscreen_pending_) | 90 if (fullscreen_pending_) |
91 return "fullscreen_pending_ has not been reset"; | 91 return "fullscreen_pending_ has not been reset"; |
92 if (!screen_mode_.IsFullscreen()) | 92 if (!screen_mode_.IsFullscreen()) |
93 return ReportError("IsFullscreen() in fullscreen", false); | 93 return ReportError("IsFullscreen() in fullscreen", false); |
94 if (!instance_->BindGraphics(graphics2d_fullscreen)) | 94 if (!instance_->BindGraphics(graphics2d_fullscreen)) |
95 return ReportError("BindGraphics() in fullscreen", false); | 95 return ReportError("BindGraphics() in fullscreen", false); |
96 | 96 |
97 // 2. Stay in fullscreen. No change. | 97 // 2. Stay in fullscreen. No change. |
98 if (!screen_mode_.SetFullscreen(true)) | 98 if (!screen_mode_.SetFullscreen(true)) |
99 return ReportError("SetFullscreen(true) in fullscreen", false); | 99 return ReportError("SetFullscreen(true) in fullscreen", false); |
100 if (!screen_mode_.IsFullscreen()) | 100 if (!screen_mode_.IsFullscreen()) |
101 return ReportError("IsFullscreen() in fullscreen^2", false); | 101 return ReportError("IsFullscreen() in fullscreen^2", false); |
102 | 102 |
103 // 3. Switch to normal. | 103 // 3. Switch to normal. |
104 // The transition is synchronous in-process and asynchornous out-of-process | 104 // The transition is synchronous in-process and asynchornous out-of-process |
105 // because proxied IsFullscreen saves a roundtrip by relying on information | 105 // because proxied IsFullscreen saves a roundtrip by relying on information |
106 // communicated via a previous call to DidChangeView. | 106 // communicated via a previous call to DidChangeView. |
107 // Graphics devices can be bound right away. | 107 // Graphics devices can be bound right away. |
108 normal_pending_ = true; | 108 normal_pending_ = true; |
109 if (!screen_mode_.SetFullscreen(false)) | 109 if (!screen_mode_.SetFullscreen(false)) |
110 return ReportError("SetFullscreen(false) in fullscreen", false); | 110 return ReportError("SetFullscreen(false) in fullscreen", false); |
111 pp::Graphics2D graphics2d_normal(instance_, pp::Size(15, 15), false); | 111 pp::Graphics2D graphics2d_normal(instance_, pp::Size(15, 15), false); |
112 if (graphics2d_normal.is_null()) | 112 if (graphics2d_normal.is_null()) |
113 return "Failed to create graphics2d_normal"; | 113 return "Failed to create graphics2d_normal"; |
114 if (!instance_->BindGraphics(graphics2d_normal)) | 114 if (!instance_->BindGraphics(graphics2d_normal)) |
115 return ReportError("BindGraphics() in normal transition", false); | 115 return ReportError("BindGraphics() in normal transition", false); |
116 if (testing_interface_->IsOutOfProcess()) { | 116 if (testing_interface_->IsOutOfProcess()) { |
117 if (!screen_mode_.IsFullscreen()) | 117 if (!screen_mode_.IsFullscreen()) |
118 return ReportError("IsFullscreen() in normal transition", false); | 118 return ReportError("IsFullscreen() in normal transition", false); |
119 normal_callback_.WaitForResult(); | 119 normal_event_.Wait(); |
120 if (normal_pending_) | 120 if (normal_pending_) |
121 return "normal_pending_ has not been reset"; | 121 return "normal_pending_ has not been reset"; |
122 } | 122 } |
123 if (screen_mode_.IsFullscreen()) | 123 if (screen_mode_.IsFullscreen()) |
124 return ReportError("IsFullscreen() in normal", true); | 124 return ReportError("IsFullscreen() in normal", true); |
125 | 125 |
126 // 4. Stay in normal. No change. | 126 // 4. Stay in normal. No change. |
127 if (!screen_mode_.SetFullscreen(false)) | 127 if (!screen_mode_.SetFullscreen(false)) |
128 return ReportError("SetFullscreen(false) in normal", false); | 128 return ReportError("SetFullscreen(false) in normal", false); |
129 if (screen_mode_.IsFullscreen()) | 129 if (screen_mode_.IsFullscreen()) |
130 return ReportError("IsFullscreen() in normal^2", true); | 130 return ReportError("IsFullscreen() in normal^2", true); |
131 | 131 |
132 PASS(); | 132 PASS(); |
133 } | 133 } |
134 | 134 |
135 // Transition to fullscreen is asynchornous ending at DidChangeView. | 135 // Transition to fullscreen is asynchornous ending at DidChangeView. |
136 // Transition to normal is synchronous in-process and asynchronous | 136 // Transition to normal is synchronous in-process and asynchronous |
137 // out-of-process ending at DidChangeView. | 137 // out-of-process ending at DidChangeView. |
138 void TestFlashFullscreen::DidChangeView(const pp::View& view) { | 138 void TestFlashFullscreen::DidChangeView(const pp::View& view) { |
139 pp::Rect position = view.GetRect(); | 139 pp::Rect position = view.GetRect(); |
140 pp::Rect clip = view.GetClipRect(); | 140 pp::Rect clip = view.GetClipRect(); |
141 if (fullscreen_pending_ && IsFullscreenView(position, clip, screen_size_)) { | 141 if (fullscreen_pending_ && IsFullscreenView(position, clip, screen_size_)) { |
142 fullscreen_pending_ = false; | 142 fullscreen_pending_ = false; |
143 pp::Module::Get()->core()->CallOnMainThread(0, fullscreen_callback_); | 143 fullscreen_event_.Signal(); |
144 } else if (normal_pending_ && | 144 } else if (normal_pending_ && |
145 !IsFullscreenView(position, clip, screen_size_)) { | 145 !IsFullscreenView(position, clip, screen_size_)) { |
146 normal_pending_ = false; | 146 normal_pending_ = false; |
147 if (testing_interface_->IsOutOfProcess()) | 147 if (testing_interface_->IsOutOfProcess()) |
148 pp::Module::Get()->core()->CallOnMainThread(0, normal_callback_); | 148 normal_event_.Signal(); |
149 } | 149 } |
150 } | 150 } |
OLD | NEW |