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

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

Issue 964403003: Make it possible to set the display mode from Chromium (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Decouple getting display mode and renderer-initiated fullscreen mode code paths Created 5 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "content/browser/frame_host/navigation_entry_impl.h" 7 #include "content/browser/frame_host/navigation_entry_impl.h"
8 #include "content/browser/renderer_host/render_widget_host_impl.h"
8 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/browser/web_contents/web_contents_view.h" 10 #include "content/browser/web_contents/web_contents_view.h"
10 #include "content/common/frame_messages.h" 11 #include "content/common/frame_messages.h"
11 #include "content/public/browser/load_notification_details.h" 12 #include "content/public/browser/load_notification_details.h"
12 #include "content/public/browser/navigation_controller.h" 13 #include "content/public/browser/navigation_controller.h"
13 #include "content/public/browser/notification_details.h" 14 #include "content/public/browser/notification_details.h"
14 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_types.h" 16 #include "content/public/browser/notification_types.h"
16 #include "content/public/browser/render_view_host.h" 17 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/render_widget_host_view.h" 18 #include "content/public/browser/render_widget_host_view.h"
(...skipping 25 matching lines...) Expand all
43 NavigateToURL(shell, GURL("about://blank")); 44 NavigateToURL(shell, GURL("about://blank"));
44 #else 45 #else
45 static_cast<WebContentsImpl*>(shell->web_contents())->GetView()-> 46 static_cast<WebContentsImpl*>(shell->web_contents())->GetView()->
46 SizeContents(size); 47 SizeContents(size);
47 #endif // defined(OS_MACOSX) 48 #endif // defined(OS_MACOSX)
48 } 49 }
49 50
50 class WebContentsImplBrowserTest : public ContentBrowserTest { 51 class WebContentsImplBrowserTest : public ContentBrowserTest {
51 public: 52 public:
52 WebContentsImplBrowserTest() {} 53 WebContentsImplBrowserTest() {}
54 void SetUp() override {
55 RenderWidgetHostImpl::DisableResizeAckCheckForTesting();
56 ContentBrowserTest::SetUp();
57 }
53 58
54 private: 59 private:
55 DISALLOW_COPY_AND_ASSIGN(WebContentsImplBrowserTest); 60 DISALLOW_COPY_AND_ASSIGN(WebContentsImplBrowserTest);
56 }; 61 };
57 62
58 // Keeps track of data from LoadNotificationDetails so we can later verify that 63 // Keeps track of data from LoadNotificationDetails so we can later verify that
59 // they are correct, after the LoadNotificationDetails object is deleted. 64 // they are correct, after the LoadNotificationDetails object is deleted.
60 class LoadStopNotificationObserver : public WindowedNotificationObserver { 65 class LoadStopNotificationObserver : public WindowedNotificationObserver {
61 public: 66 public:
62 LoadStopNotificationObserver(NavigationController* controller) 67 LoadStopNotificationObserver(NavigationController* controller)
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 639 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
635 scoped_ptr<FirstVisuallyNonEmptyPaintObserver> observer( 640 scoped_ptr<FirstVisuallyNonEmptyPaintObserver> observer(
636 new FirstVisuallyNonEmptyPaintObserver(shell())); 641 new FirstVisuallyNonEmptyPaintObserver(shell()));
637 642
638 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); 643 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"));
639 644
640 observer->WaitForDidFirstVisuallyNonEmptyPaint(); 645 observer->WaitForDidFirstVisuallyNonEmptyPaint();
641 ASSERT_TRUE(observer->did_fist_visually_non_empty_paint_); 646 ASSERT_TRUE(observer->did_fist_visually_non_empty_paint_);
642 } 647 }
643 648
649 namespace {
650
651 class WebDisplayModeDelegate : public WebContentsDelegate {
652 public:
653 explicit WebDisplayModeDelegate(blink::WebDisplayMode mode) : mode_(mode) { }
654 blink::WebDisplayMode GetDisplayMode(
655 const WebContents* source) const override { return mode_; }
656 void set_mode(blink::WebDisplayMode mode) { mode_ = mode; }
657 private:
658 blink::WebDisplayMode mode_;
659 };
660
661 }
662
663 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, ChangeDisplayMode) {
664 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
665 WebDisplayModeDelegate delegate(blink::WebDisplayModeMinimalUi);
666 shell()->web_contents()->SetDelegate(&delegate);
667
668 NavigateToURL(shell(), GURL("about://blank"));
669
670 ASSERT_TRUE(ExecuteScript(shell()->web_contents(),
671 "document.title = "
672 " window.matchMedia('(display-mode:"
673 " minimal-ui)').matches"));
674 EXPECT_EQ(base::ASCIIToUTF16("true"), shell()->web_contents()->GetTitle());
675
676 delegate.set_mode(blink::WebDisplayModeFullscreen);
677 // Simulate widget is entering fullscreen (changing size is enough).
678 gfx::Size size(500, 500);
679 ResizeWebContentsView(shell(), size, false);
680
681 ASSERT_TRUE(ExecuteScript(shell()->web_contents(),
682 "document.title = "
683 " window.matchMedia('(display-mode:"
684 " fullscreen)').matches"));
685 EXPECT_EQ(base::ASCIIToUTF16("true"), shell()->web_contents()->GetTitle());
686 }
687
644 } // namespace content 688 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698