| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/exclusive_access/exclusive_access_controller_manager
.h" |
| 11 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 12 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/test/base/interactive_test_utils.h" | 14 #include "chrome/test/base/interactive_test_utils.h" |
| 14 #include "chrome/test/ppapi/ppapi_test.h" | 15 #include "chrome/test/ppapi/ppapi_test.h" |
| 15 #include "content/public/browser/render_widget_host.h" | 16 #include "content/public/browser/render_widget_host.h" |
| 16 #include "content/public/browser/render_widget_host_view.h" | 17 #include "content/public/browser/render_widget_host_view.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/test/test_utils.h" | 19 #include "content/public/test/test_utils.h" |
| 19 #include "third_party/skia/include/core/SkColor.h" | 20 #include "third_party/skia/include/core/SkColor.h" |
| 20 | 21 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 expected_in_fullscreen))) | 141 expected_in_fullscreen))) |
| 141 return false; | 142 return false; |
| 142 | 143 |
| 143 if (expected_in_fullscreen) { | 144 if (expected_in_fullscreen) { |
| 144 if (!GetActiveWebContents()->GetFullscreenRenderWidgetHostView()) { | 145 if (!GetActiveWebContents()->GetFullscreenRenderWidgetHostView()) { |
| 145 ADD_FAILURE() | 146 ADD_FAILURE() |
| 146 << "WebContents should have a fullscreen RenderWidgetHostView."; | 147 << "WebContents should have a fullscreen RenderWidgetHostView."; |
| 147 return false; | 148 return false; |
| 148 } | 149 } |
| 149 EXPECT_EQ(GetActiveWebContents()->GetCapturerCount() > 0, | 150 EXPECT_EQ(GetActiveWebContents()->GetCapturerCount() > 0, |
| 150 !browser()->fullscreen_controller()-> | 151 !browser() |
| 151 IsWindowFullscreenForTabOrPending()); | 152 ->GetExclusiveAccessControllerManager() |
| 153 ->GetFullscreenController() |
| 154 ->IsWindowFullscreenForTabOrPending()); |
| 152 } | 155 } |
| 153 | 156 |
| 154 return true; | 157 return true; |
| 155 } | 158 } |
| 156 | 159 |
| 157 bool ObserveFlashHasFocus(content::WebContents* contents, | 160 bool ObserveFlashHasFocus(content::WebContents* contents, |
| 158 bool expected_to_have_focus) const { | 161 bool expected_to_have_focus) const { |
| 159 if (!RunLoopUntil(base::Bind( | 162 if (!RunLoopUntil(base::Bind( |
| 160 &FlashFullscreenInteractiveBrowserTest::IsObservingFlashHasFocus, | 163 &FlashFullscreenInteractiveBrowserTest::IsObservingFlashHasFocus, |
| 161 base::Unretained(this), | 164 base::Unretained(this), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 180 bool ObserveFlashFillColor(SkColor expected_color) const { | 183 bool ObserveFlashFillColor(SkColor expected_color) const { |
| 181 return RunLoopUntil(base::Bind( | 184 return RunLoopUntil(base::Bind( |
| 182 &FlashFullscreenInteractiveBrowserTest::IsObservingFlashFillColor, | 185 &FlashFullscreenInteractiveBrowserTest::IsObservingFlashFillColor, |
| 183 base::Unretained(this), | 186 base::Unretained(this), |
| 184 expected_color)); | 187 expected_color)); |
| 185 } | 188 } |
| 186 | 189 |
| 187 private: | 190 private: |
| 188 bool IsObservingTabInFullscreen(content::WebContents* contents, | 191 bool IsObservingTabInFullscreen(content::WebContents* contents, |
| 189 bool expected_in_fullscreen) const { | 192 bool expected_in_fullscreen) const { |
| 190 return expected_in_fullscreen == browser()->fullscreen_controller()-> | 193 return expected_in_fullscreen == |
| 191 IsFullscreenForTabOrPending(contents); | 194 browser() |
| 195 ->GetExclusiveAccessControllerManager() |
| 196 ->GetFullscreenController() |
| 197 ->IsFullscreenForTabOrPending(contents); |
| 192 } | 198 } |
| 193 | 199 |
| 194 bool IsObservingFlashHasFocus(content::WebContents* contents, | 200 bool IsObservingFlashHasFocus(content::WebContents* contents, |
| 195 bool expected_to_have_focus) const { | 201 bool expected_to_have_focus) const { |
| 196 content::RenderWidgetHostView* const flash_fs_view = | 202 content::RenderWidgetHostView* const flash_fs_view = |
| 197 contents->GetFullscreenRenderWidgetHostView(); | 203 contents->GetFullscreenRenderWidgetHostView(); |
| 198 const bool flash_has_focus = flash_fs_view && flash_fs_view->HasFocus(); | 204 const bool flash_has_focus = flash_fs_view && flash_fs_view->HasFocus(); |
| 199 return flash_has_focus == expected_to_have_focus; | 205 return flash_has_focus == expected_to_have_focus; |
| 200 } | 206 } |
| 201 | 207 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorRED)); | 347 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorRED)); |
| 342 PressSpacebar(); | 348 PressSpacebar(); |
| 343 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorBLUE)); | 349 ASSERT_TRUE(ObserveFlashFillColor(SK_ColorBLUE)); |
| 344 | 350 |
| 345 // Test that the Escape key is handled as an exit fullscreen command while the | 351 // Test that the Escape key is handled as an exit fullscreen command while the |
| 346 // Flash widget has the focus. | 352 // Flash widget has the focus. |
| 347 EXPECT_TRUE(ObserveFlashHasFocus(first_tab_contents, true)); | 353 EXPECT_TRUE(ObserveFlashHasFocus(first_tab_contents, true)); |
| 348 PressEscape(); | 354 PressEscape(); |
| 349 EXPECT_TRUE(ObserveTabIsInFullscreen(false)); | 355 EXPECT_TRUE(ObserveTabIsInFullscreen(false)); |
| 350 } | 356 } |
| OLD | NEW |