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

Side by Side Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 789533002: Fullscreen: make fullscreen requests come from RenderFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update webcontentsdelegateandroid Created 6 years 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/browser/frame_host/cross_site_transferring_request.h" 7 #include "content/browser/frame_host/cross_site_transferring_request.h"
8 #include "content/browser/frame_host/interstitial_page_impl.h" 8 #include "content/browser/frame_host/interstitial_page_impl.h"
9 #include "content/browser/frame_host/navigation_entry_impl.h" 9 #include "content/browser/frame_host/navigation_entry_impl.h"
10 #include "content/browser/media/audio_stream_monitor.h" 10 #include "content/browser/media/audio_stream_monitor.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 }; 293 };
294 294
295 // Pretends to be a normal browser that receives toggles and transitions to/from 295 // Pretends to be a normal browser that receives toggles and transitions to/from
296 // a fullscreened state. 296 // a fullscreened state.
297 class FakeFullscreenDelegate : public WebContentsDelegate { 297 class FakeFullscreenDelegate : public WebContentsDelegate {
298 public: 298 public:
299 FakeFullscreenDelegate() : fullscreened_contents_(NULL) {} 299 FakeFullscreenDelegate() : fullscreened_contents_(NULL) {}
300 ~FakeFullscreenDelegate() override {} 300 ~FakeFullscreenDelegate() override {}
301 301
302 void ToggleFullscreenModeForTab(WebContents* web_contents, 302 void ToggleFullscreenModeForTab(WebContents* web_contents,
303 const GURL& origin,
303 bool enter_fullscreen) override { 304 bool enter_fullscreen) override {
304 fullscreened_contents_ = enter_fullscreen ? web_contents : NULL; 305 fullscreened_contents_ = enter_fullscreen ? web_contents : NULL;
305 } 306 }
306 307
307 bool IsFullscreenForTabOrPending( 308 bool IsFullscreenForTabOrPending(
308 const WebContents* web_contents) const override { 309 const WebContents* web_contents) const override {
309 return fullscreened_contents_ && web_contents == fullscreened_contents_; 310 return fullscreened_contents_ && web_contents == fullscreened_contents_;
310 } 311 }
311 312
312 private: 313 private:
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 const GURL url("http://www.google.com"); 1293 const GURL url("http://www.google.com");
1293 controller().LoadURL( 1294 controller().LoadURL(
1294 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 1295 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
1295 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); 1296 contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED);
1296 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); 1297 EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
1297 1298
1298 // Toggle fullscreen mode on (as if initiated via IPC from renderer). 1299 // Toggle fullscreen mode on (as if initiated via IPC from renderer).
1299 EXPECT_FALSE(orig_rvh->IsFullscreen()); 1300 EXPECT_FALSE(orig_rvh->IsFullscreen());
1300 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); 1301 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab());
1301 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); 1302 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1302 orig_rvh->OnMessageReceived( 1303 orig_rfh->OnMessageReceived(
1303 ViewHostMsg_ToggleFullscreen(orig_rvh->GetRoutingID(), true)); 1304 FrameHostMsg_ToggleFullscreen(orig_rfh->GetRoutingID(), true));
1304 EXPECT_TRUE(orig_rvh->IsFullscreen()); 1305 EXPECT_TRUE(orig_rvh->IsFullscreen());
1305 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab()); 1306 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab());
1306 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents())); 1307 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1307 1308
1308 // Navigate to a new site. 1309 // Navigate to a new site.
1309 const GURL url2("http://www.yahoo.com"); 1310 const GURL url2("http://www.yahoo.com");
1310 controller().LoadURL( 1311 controller().LoadURL(
1311 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 1312 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
1312 TestRenderFrameHost* const pending_rfh = contents()->GetPendingMainFrame(); 1313 TestRenderFrameHost* const pending_rfh = contents()->GetPendingMainFrame();
1313 contents()->TestDidNavigate( 1314 contents()->TestDidNavigate(
(...skipping 30 matching lines...) Expand all
1344 contents()->TestDidNavigate(orig_rfh, 2, url2, ui::PAGE_TRANSITION_TYPED); 1345 contents()->TestDidNavigate(orig_rfh, 2, url2, ui::PAGE_TRANSITION_TYPED);
1345 EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); 1346 EXPECT_EQ(orig_rfh, contents()->GetMainFrame());
1346 1347
1347 // Sanity-check: Confirm we're not starting out in fullscreen mode. 1348 // Sanity-check: Confirm we're not starting out in fullscreen mode.
1348 EXPECT_FALSE(orig_rvh->IsFullscreen()); 1349 EXPECT_FALSE(orig_rvh->IsFullscreen());
1349 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); 1350 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab());
1350 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); 1351 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1351 1352
1352 for (int i = 0; i < 2; ++i) { 1353 for (int i = 0; i < 2; ++i) {
1353 // Toggle fullscreen mode on (as if initiated via IPC from renderer). 1354 // Toggle fullscreen mode on (as if initiated via IPC from renderer).
1354 orig_rvh->OnMessageReceived( 1355 orig_rfh->OnMessageReceived(
1355 ViewHostMsg_ToggleFullscreen(orig_rvh->GetRoutingID(), true)); 1356 FrameHostMsg_ToggleFullscreen(orig_rfh->GetRoutingID(), true));
1356 EXPECT_TRUE(orig_rvh->IsFullscreen()); 1357 EXPECT_TRUE(orig_rvh->IsFullscreen());
1357 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab()); 1358 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab());
1358 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents())); 1359 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1359 1360
1360 // Navigate backward (or forward). 1361 // Navigate backward (or forward).
1361 if (i == 0) 1362 if (i == 0)
1362 controller().GoBack(); 1363 controller().GoBack();
1363 else 1364 else
1364 controller().GoForward(); 1365 controller().GoForward();
1365 EXPECT_FALSE(contents()->cross_navigation_pending()); 1366 EXPECT_FALSE(contents()->cross_navigation_pending());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 const GURL url("http://www.google.com"); 1403 const GURL url("http://www.google.com");
1403 controller().LoadURL( 1404 controller().LoadURL(
1404 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 1405 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
1405 contents()->TestDidNavigate( 1406 contents()->TestDidNavigate(
1406 contents()->GetMainFrame(), 1, url, ui::PAGE_TRANSITION_TYPED); 1407 contents()->GetMainFrame(), 1, url, ui::PAGE_TRANSITION_TYPED);
1407 1408
1408 // Toggle fullscreen mode on (as if initiated via IPC from renderer). 1409 // Toggle fullscreen mode on (as if initiated via IPC from renderer).
1409 EXPECT_FALSE(test_rvh()->IsFullscreen()); 1410 EXPECT_FALSE(test_rvh()->IsFullscreen());
1410 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab()); 1411 EXPECT_FALSE(contents()->IsFullscreenForCurrentTab());
1411 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents())); 1412 EXPECT_FALSE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1412 test_rvh()->OnMessageReceived( 1413 contents()->GetMainFrame()->OnMessageReceived(FrameHostMsg_ToggleFullscreen(
1413 ViewHostMsg_ToggleFullscreen(test_rvh()->GetRoutingID(), true)); 1414 contents()->GetMainFrame()->GetRoutingID(), true));
1414 EXPECT_TRUE(test_rvh()->IsFullscreen()); 1415 EXPECT_TRUE(test_rvh()->IsFullscreen());
1415 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab()); 1416 EXPECT_TRUE(contents()->IsFullscreenForCurrentTab());
1416 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents())); 1417 EXPECT_TRUE(fake_delegate.IsFullscreenForTabOrPending(contents()));
1417 1418
1418 // Crash the renderer. 1419 // Crash the renderer.
1419 test_rvh()->OnMessageReceived( 1420 test_rvh()->OnMessageReceived(
1420 ViewHostMsg_RenderProcessGone( 1421 ViewHostMsg_RenderProcessGone(
1421 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); 1422 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1));
1422 1423
1423 // Confirm fullscreen has exited. 1424 // Confirm fullscreen has exited.
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2785 2786
2786 // Destroy the remote player. No power save blockers should remain. 2787 // Destroy the remote player. No power save blockers should remain.
2787 rfh->OnMessageReceived( 2788 rfh->OnMessageReceived(
2788 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); 2789 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId));
2789 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); 2790 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing());
2790 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); 2791 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing());
2791 } 2792 }
2792 #endif 2793 #endif
2793 2794
2794 } // namespace content 2795 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698