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

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

Issue 2684993011: Revert of Make TestRenderWidgetHostView::Show/Hide call through to RWHI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@crash
Patch Set: Created 3 years, 10 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 (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 <stdint.h> 5 #include <stdint.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 void TestRenderViewTerminated(base::TerminationStatus status, 156 void TestRenderViewTerminated(base::TerminationStatus status,
157 int error_code) { 157 int error_code) {
158 RenderViewTerminated(GetMainFrame()->GetRenderViewHost(), status, 158 RenderViewTerminated(GetMainFrame()->GetRenderViewHost(), status,
159 error_code); 159 error_code);
160 } 160 }
161 161
162 bool is_showing() const { 162 bool is_showing() const {
163 return static_cast<TestRenderWidgetHostView*>( 163 return static_cast<TestRenderWidgetHostView*>(
164 GetMainFrame()->GetRenderViewHost()->GetWidget()->GetView()) 164 GetMainFrame()->GetRenderViewHost()->GetWidget()->GetView())
165 ->IsShowing(); 165 ->is_showing();
166 } 166 }
167 167
168 void ClearStates() { 168 void ClearStates() {
169 state_ = nullptr; 169 state_ = nullptr;
170 deleted_ = nullptr; 170 deleted_ = nullptr;
171 delegate_ = nullptr; 171 delegate_ = nullptr;
172 } 172 }
173 173
174 void CommandReceived() { 174 void CommandReceived() {
175 command_received_count_++; 175 command_received_count_++;
(...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 TestInterstitialPage::InterstitialState state = 1677 TestInterstitialPage::InterstitialState state =
1678 TestInterstitialPage::INVALID; 1678 TestInterstitialPage::INVALID;
1679 bool deleted = false; 1679 bool deleted = false;
1680 GURL url2("http://interstitial"); 1680 GURL url2("http://interstitial");
1681 TestInterstitialPage* interstitial = 1681 TestInterstitialPage* interstitial =
1682 new TestInterstitialPage(contents(), true, url2, &state, &deleted); 1682 new TestInterstitialPage(contents(), true, url2, &state, &deleted);
1683 TestInterstitialPageStateGuard state_guard(interstitial); 1683 TestInterstitialPageStateGuard state_guard(interstitial);
1684 interstitial->Show(); 1684 interstitial->Show();
1685 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); 1685 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID();
1686 // The interstitial should not show until its navigation has committed. 1686 // The interstitial should not show until its navigation has committed.
1687 EXPECT_FALSE(interstitial->is_showing());
1687 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1688 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1688 EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); 1689 EXPECT_EQ(nullptr, contents()->GetInterstitialPage());
1689 // Let's commit the interstitial navigation. 1690 // Let's commit the interstitial navigation.
1690 interstitial->TestDidNavigate(interstitial_entry_id, true, url2); 1691 interstitial->TestDidNavigate(interstitial_entry_id, true, url2);
1691 EXPECT_TRUE(interstitial->is_showing()); 1692 EXPECT_TRUE(interstitial->is_showing());
1692 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1693 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1693 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1694 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1694 entry = controller().GetVisibleEntry(); 1695 entry = controller().GetVisibleEntry();
1695 ASSERT_NE(nullptr, entry); 1696 ASSERT_NE(nullptr, entry);
1696 EXPECT_TRUE(entry->GetURL() == url2); 1697 EXPECT_TRUE(entry->GetURL() == url2);
(...skipping 27 matching lines...) Expand all
1724 TestInterstitialPage::InterstitialState state = 1725 TestInterstitialPage::InterstitialState state =
1725 TestInterstitialPage::INVALID; 1726 TestInterstitialPage::INVALID;
1726 bool deleted = false; 1727 bool deleted = false;
1727 GURL url2("http://interstitial"); 1728 GURL url2("http://interstitial");
1728 TestInterstitialPage* interstitial = 1729 TestInterstitialPage* interstitial =
1729 new TestInterstitialPage(contents(), true, url2, &state, &deleted); 1730 new TestInterstitialPage(contents(), true, url2, &state, &deleted);
1730 TestInterstitialPageStateGuard state_guard(interstitial); 1731 TestInterstitialPageStateGuard state_guard(interstitial);
1731 interstitial->Show(); 1732 interstitial->Show();
1732 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); 1733 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID();
1733 // The interstitial should not show until its navigation has committed. 1734 // The interstitial should not show until its navigation has committed.
1735 EXPECT_FALSE(interstitial->is_showing());
1734 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1736 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1735 EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); 1737 EXPECT_EQ(nullptr, contents()->GetInterstitialPage());
1736 // Let's commit the interstitial navigation. 1738 // Let's commit the interstitial navigation.
1737 interstitial->TestDidNavigate(interstitial_entry_id, true, url2); 1739 interstitial->TestDidNavigate(interstitial_entry_id, true, url2);
1738 EXPECT_TRUE(interstitial->is_showing()); 1740 EXPECT_TRUE(interstitial->is_showing());
1739 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1741 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1740 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1742 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1741 NavigationEntry* entry = controller().GetVisibleEntry(); 1743 NavigationEntry* entry = controller().GetVisibleEntry();
1742 ASSERT_NE(nullptr, entry); 1744 ASSERT_NE(nullptr, entry);
1743 EXPECT_TRUE(entry->GetURL() == url2); 1745 EXPECT_TRUE(entry->GetURL() == url2);
(...skipping 24 matching lines...) Expand all
1768 // Show an interstitial. 1770 // Show an interstitial.
1769 TestInterstitialPage::InterstitialState state = 1771 TestInterstitialPage::InterstitialState state =
1770 TestInterstitialPage::INVALID; 1772 TestInterstitialPage::INVALID;
1771 bool deleted = false; 1773 bool deleted = false;
1772 GURL url2("http://interstitial"); 1774 GURL url2("http://interstitial");
1773 TestInterstitialPage* interstitial = 1775 TestInterstitialPage* interstitial =
1774 new TestInterstitialPage(contents(), false, url2, &state, &deleted); 1776 new TestInterstitialPage(contents(), false, url2, &state, &deleted);
1775 TestInterstitialPageStateGuard state_guard(interstitial); 1777 TestInterstitialPageStateGuard state_guard(interstitial);
1776 interstitial->Show(); 1778 interstitial->Show();
1777 // The interstitial should not show until its navigation has committed. 1779 // The interstitial should not show until its navigation has committed.
1780 EXPECT_FALSE(interstitial->is_showing());
1778 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1781 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1779 EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); 1782 EXPECT_EQ(nullptr, contents()->GetInterstitialPage());
1780 // Let's commit the interstitial navigation. 1783 // Let's commit the interstitial navigation.
1781 interstitial->TestDidNavigate(0, true, url2); 1784 interstitial->TestDidNavigate(0, true, url2);
1782 EXPECT_TRUE(interstitial->is_showing()); 1785 EXPECT_TRUE(interstitial->is_showing());
1783 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1786 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1784 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1787 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1785 NavigationEntry* entry = controller().GetVisibleEntry(); 1788 NavigationEntry* entry = controller().GetVisibleEntry();
1786 ASSERT_NE(nullptr, entry); 1789 ASSERT_NE(nullptr, entry);
1787 // The URL specified to the interstitial should have been ignored. 1790 // The URL specified to the interstitial should have been ignored.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 TestInterstitialPage::InterstitialState state = 1822 TestInterstitialPage::InterstitialState state =
1820 TestInterstitialPage::INVALID; 1823 TestInterstitialPage::INVALID;
1821 bool deleted = false; 1824 bool deleted = false;
1822 GURL url2("http://interstitial"); 1825 GURL url2("http://interstitial");
1823 TestInterstitialPage* interstitial = 1826 TestInterstitialPage* interstitial =
1824 new TestInterstitialPage(contents(), true, url2, &state, &deleted); 1827 new TestInterstitialPage(contents(), true, url2, &state, &deleted);
1825 TestInterstitialPageStateGuard state_guard(interstitial); 1828 TestInterstitialPageStateGuard state_guard(interstitial);
1826 interstitial->Show(); 1829 interstitial->Show();
1827 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); 1830 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID();
1828 // The interstitial should not show until its navigation has committed. 1831 // The interstitial should not show until its navigation has committed.
1832 EXPECT_FALSE(interstitial->is_showing());
1829 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1833 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1830 EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); 1834 EXPECT_EQ(nullptr, contents()->GetInterstitialPage());
1831 // Let's commit the interstitial navigation. 1835 // Let's commit the interstitial navigation.
1832 interstitial->TestDidNavigate(interstitial_entry_id, true, url2); 1836 interstitial->TestDidNavigate(interstitial_entry_id, true, url2);
1833 EXPECT_TRUE(interstitial->is_showing()); 1837 EXPECT_TRUE(interstitial->is_showing());
1834 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1838 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1835 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1839 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1836 NavigationEntry* entry = controller().GetVisibleEntry(); 1840 NavigationEntry* entry = controller().GetVisibleEntry();
1837 ASSERT_NE(nullptr, entry); 1841 ASSERT_NE(nullptr, entry);
1838 EXPECT_TRUE(entry->GetURL() == url2); 1842 EXPECT_TRUE(entry->GetURL() == url2);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 TestInterstitialPage::InterstitialState state = 1882 TestInterstitialPage::InterstitialState state =
1879 TestInterstitialPage::INVALID; 1883 TestInterstitialPage::INVALID;
1880 bool deleted = false; 1884 bool deleted = false;
1881 GURL url2("http://interstitial"); 1885 GURL url2("http://interstitial");
1882 TestInterstitialPage* interstitial = 1886 TestInterstitialPage* interstitial =
1883 new TestInterstitialPage(contents(), true, url2, &state, &deleted); 1887 new TestInterstitialPage(contents(), true, url2, &state, &deleted);
1884 TestInterstitialPageStateGuard state_guard(interstitial); 1888 TestInterstitialPageStateGuard state_guard(interstitial);
1885 interstitial->Show(); 1889 interstitial->Show();
1886 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); 1890 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID();
1887 // The interstitial should not show until its navigation has committed. 1891 // The interstitial should not show until its navigation has committed.
1892 EXPECT_FALSE(interstitial->is_showing());
1888 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1893 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1889 EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); 1894 EXPECT_EQ(nullptr, contents()->GetInterstitialPage());
1890 // Let's commit the interstitial navigation. 1895 // Let's commit the interstitial navigation.
1891 interstitial->TestDidNavigate(interstitial_entry_id, true, url2); 1896 interstitial->TestDidNavigate(interstitial_entry_id, true, url2);
1892 EXPECT_TRUE(interstitial->is_showing()); 1897 EXPECT_TRUE(interstitial->is_showing());
1893 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1898 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1894 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1899 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1895 NavigationEntry* entry = controller().GetVisibleEntry(); 1900 NavigationEntry* entry = controller().GetVisibleEntry();
1896 ASSERT_NE(nullptr, entry); 1901 ASSERT_NE(nullptr, entry);
1897 EXPECT_TRUE(entry->GetURL() == url2); 1902 EXPECT_TRUE(entry->GetURL() == url2);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 // Show an interstitial. 1939 // Show an interstitial.
1935 TestInterstitialPage::InterstitialState state = 1940 TestInterstitialPage::InterstitialState state =
1936 TestInterstitialPage::INVALID; 1941 TestInterstitialPage::INVALID;
1937 bool deleted = false; 1942 bool deleted = false;
1938 GURL url2("http://interstitial"); 1943 GURL url2("http://interstitial");
1939 TestInterstitialPage* interstitial = 1944 TestInterstitialPage* interstitial =
1940 new TestInterstitialPage(contents(), false, url2, &state, &deleted); 1945 new TestInterstitialPage(contents(), false, url2, &state, &deleted);
1941 TestInterstitialPageStateGuard state_guard(interstitial); 1946 TestInterstitialPageStateGuard state_guard(interstitial);
1942 interstitial->Show(); 1947 interstitial->Show();
1943 // The interstitial should not show until its navigation has committed. 1948 // The interstitial should not show until its navigation has committed.
1949 EXPECT_FALSE(interstitial->is_showing());
1944 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 1950 EXPECT_FALSE(contents()->ShowingInterstitialPage());
1945 EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); 1951 EXPECT_EQ(nullptr, contents()->GetInterstitialPage());
1946 // Let's commit the interstitial navigation. 1952 // Let's commit the interstitial navigation.
1947 interstitial->TestDidNavigate(0, true, url2); 1953 interstitial->TestDidNavigate(0, true, url2);
1948 EXPECT_TRUE(interstitial->is_showing()); 1954 EXPECT_TRUE(interstitial->is_showing());
1949 EXPECT_TRUE(contents()->ShowingInterstitialPage()); 1955 EXPECT_TRUE(contents()->ShowingInterstitialPage());
1950 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); 1956 EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial);
1951 NavigationEntry* entry = controller().GetVisibleEntry(); 1957 NavigationEntry* entry = controller().GetVisibleEntry();
1952 ASSERT_NE(nullptr, entry); 1958 ASSERT_NE(nullptr, entry);
1953 // The URL specified to the interstitial should have been ignored. 1959 // The URL specified to the interstitial should have been ignored.
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2318 &state, &deleted); 2324 &state, &deleted);
2319 TestInterstitialPageStateGuard state_guard(interstitial); 2325 TestInterstitialPageStateGuard state_guard(interstitial);
2320 interstitial->Show(); 2326 interstitial->Show();
2321 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); 2327 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID();
2322 2328
2323 // Let's simulate a navigation initiated from the browser before the 2329 // Let's simulate a navigation initiated from the browser before the
2324 // interstitial finishes loading. 2330 // interstitial finishes loading.
2325 const GURL url("http://www.google.com"); 2331 const GURL url("http://www.google.com");
2326 controller().LoadURL( 2332 controller().LoadURL(
2327 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 2333 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
2328 EXPECT_FALSE(contents()->ShowingInterstitialPage()); 2334 EXPECT_FALSE(interstitial->is_showing());
2329 RunAllPendingInMessageLoop(); 2335 RunAllPendingInMessageLoop();
2330 ASSERT_FALSE(deleted); 2336 ASSERT_FALSE(deleted);
2331 2337
2332 // Now let's make the interstitial navigation commit. 2338 // Now let's make the interstitial navigation commit.
2333 interstitial->TestDidNavigate(interstitial_entry_id, true, 2339 interstitial->TestDidNavigate(interstitial_entry_id, true,
2334 interstitial_url); 2340 interstitial_url);
2335 2341
2336 // After it loaded the interstitial should be gone. 2342 // After it loaded the interstitial should be gone.
2337 EXPECT_EQ(TestInterstitialPage::CANCELED, state); 2343 EXPECT_EQ(TestInterstitialPage::CANCELED, state);
2338 2344
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2690 2696
2691 TEST_F(WebContentsImplTest, CapturerPreventsHiding) { 2697 TEST_F(WebContentsImplTest, CapturerPreventsHiding) {
2692 const gfx::Size original_preferred_size(1024, 768); 2698 const gfx::Size original_preferred_size(1024, 768);
2693 contents()->UpdatePreferredSize(original_preferred_size); 2699 contents()->UpdatePreferredSize(original_preferred_size);
2694 2700
2695 TestRenderWidgetHostView* view = static_cast<TestRenderWidgetHostView*>( 2701 TestRenderWidgetHostView* view = static_cast<TestRenderWidgetHostView*>(
2696 main_test_rfh()->GetRenderViewHost()->GetWidget()->GetView()); 2702 main_test_rfh()->GetRenderViewHost()->GetWidget()->GetView());
2697 2703
2698 // With no capturers, setting and un-setting occlusion should change the 2704 // With no capturers, setting and un-setting occlusion should change the
2699 // view's occlusion state. 2705 // view's occlusion state.
2700 EXPECT_TRUE(view->IsShowing()); 2706 EXPECT_FALSE(view->is_showing());
2707 contents()->WasShown();
2708 EXPECT_TRUE(view->is_showing());
2701 contents()->WasHidden(); 2709 contents()->WasHidden();
2702 EXPECT_FALSE(view->IsShowing()); 2710 EXPECT_FALSE(view->is_showing());
2703 contents()->WasShown(); 2711 contents()->WasShown();
2704 EXPECT_TRUE(view->IsShowing()); 2712 EXPECT_TRUE(view->is_showing());
2705 2713
2706 // Add a capturer and try to hide the contents. The view will remain visible. 2714 // Add a capturer and try to hide the contents. The view will remain visible.
2707 contents()->IncrementCapturerCount(gfx::Size()); 2715 contents()->IncrementCapturerCount(gfx::Size());
2708 contents()->WasHidden(); 2716 contents()->WasHidden();
2709 EXPECT_TRUE(view->IsShowing()); 2717 EXPECT_TRUE(view->is_showing());
2710 2718
2711 // Remove the capturer, and the WasHidden should take effect. 2719 // Remove the capturer, and the WasHidden should take effect.
2712 contents()->DecrementCapturerCount(); 2720 contents()->DecrementCapturerCount();
2713 EXPECT_FALSE(view->IsShowing()); 2721 EXPECT_FALSE(view->is_showing());
2714 } 2722 }
2715 2723
2716 TEST_F(WebContentsImplTest, CapturerPreventsOcclusion) { 2724 TEST_F(WebContentsImplTest, CapturerPreventsOcclusion) {
2717 const gfx::Size original_preferred_size(1024, 768); 2725 const gfx::Size original_preferred_size(1024, 768);
2718 contents()->UpdatePreferredSize(original_preferred_size); 2726 contents()->UpdatePreferredSize(original_preferred_size);
2719 2727
2720 TestRenderWidgetHostView* view = static_cast<TestRenderWidgetHostView*>( 2728 TestRenderWidgetHostView* view = static_cast<TestRenderWidgetHostView*>(
2721 main_test_rfh()->GetRenderViewHost()->GetWidget()->GetView()); 2729 main_test_rfh()->GetRenderViewHost()->GetWidget()->GetView());
2722 2730
2723 // With no capturers, setting and un-setting occlusion should change the 2731 // With no capturers, setting and un-setting occlusion should change the
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
3428 // An automatic navigation. 3436 // An automatic navigation.
3429 main_test_rfh()->SendNavigateWithModificationCallback( 3437 main_test_rfh()->SendNavigateWithModificationCallback(
3430 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); 3438 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture));
3431 3439
3432 EXPECT_EQ(1u, dialog_manager.reset_count()); 3440 EXPECT_EQ(1u, dialog_manager.reset_count());
3433 3441
3434 contents()->SetJavaScriptDialogManagerForTesting(nullptr); 3442 contents()->SetJavaScriptDialogManagerForTesting(nullptr);
3435 } 3443 }
3436 3444
3437 } // namespace content 3445 } // namespace content
OLDNEW
« no previous file with comments | « components/visitedlink/test/visitedlink_unittest.cc ('k') | content/public/test/test_renderer_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698