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

Side by Side Diff: chrome/browser/apps/guest_view/web_view_browsertest.cc

Issue 1592573002: Fixing WebViewVisibilityTests for OOPIF-<webview>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added Tests and TODO Created 4 years, 11 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 <queue> 5 #include <queue>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 content::WebContents* embedder_web_contents_; 721 content::WebContents* embedder_web_contents_;
722 }; 722 };
723 723
724 // The following test suits are created to group tests based on specific 724 // The following test suits are created to group tests based on specific
725 // features of <webview>. 725 // features of <webview>.
726 // These features current would not work with --site-per-process and is 726 // These features current would not work with --site-per-process and is
727 // disabled on site isolation FYI bots. 727 // disabled on site isolation FYI bots.
728 class WebViewNewWindowTest : public WebViewTest {}; 728 class WebViewNewWindowTest : public WebViewTest {};
729 class WebViewSizeTest : public WebViewTest {}; 729 class WebViewSizeTest : public WebViewTest {};
730 class WebViewSpeechAPITest : public WebViewTest {}; 730 class WebViewSpeechAPITest : public WebViewTest {};
731 class WebViewVisibilityTest : public WebViewTest {}; 731 class WebViewVisibilityTest : public WebViewTest,
732 public ::testing::WithParamInterface<bool> {
733 protected:
734 void SetUpCommandLine(base::CommandLine* command_line) override {
735 if (GetParam())
736 command_line->AppendSwitchASCII(
737 switches::kSitePerProcess, switches::kUseCrossProcessFramesForGuests);
738
739 WebViewTest::SetUpCommandLine(command_line);
740 }
741 };
732 742
733 // Test suite that containts tests that are meant to run with and without 743 // Test suite that containts tests that are meant to run with and without
734 // --site-per-process. 744 // --site-per-process.
735 class WebViewCommonTest : public extensions::PlatformAppBrowserTest {}; 745 class WebViewCommonTest : public extensions::PlatformAppBrowserTest {};
736 746
737 class WebViewDPITest : public WebViewTest { 747 class WebViewDPITest : public WebViewTest {
738 protected: 748 protected:
739 void SetUpCommandLine(base::CommandLine* command_line) override { 749 void SetUpCommandLine(base::CommandLine* command_line) override {
740 WebViewTest::SetUpCommandLine(command_line); 750 WebViewTest::SetUpCommandLine(command_line);
741 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, 751 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 812
803 EXPECT_TRUE(embedder->IsAudioMuted()); 813 EXPECT_TRUE(embedder->IsAudioMuted());
804 WebContentsAudioMutedObserver observer(guest); 814 WebContentsAudioMutedObserver observer(guest);
805 // If the guest hasn't attached yet, it may not have received the muting 815 // If the guest hasn't attached yet, it may not have received the muting
806 // update, in which case we should wait until it does. 816 // update, in which case we should wait until it does.
807 if (!guest->IsAudioMuted()) 817 if (!guest->IsAudioMuted())
808 observer.WaitForUpdate(); 818 observer.WaitForUpdate();
809 EXPECT_TRUE(guest->IsAudioMuted()); 819 EXPECT_TRUE(guest->IsAudioMuted());
810 } 820 }
811 821
822 // TODO(ekaramad): Remove this and revert the TEST_P to TEST_F once
823 // crbug.com/578884 is resolved.
824 INSTANTIATE_TEST_CASE_P(ForOOPIFAndNonOOPIFWebView,
825 WebViewVisibilityTest,
826 ::testing::Bool());
827
812 // This test verifies that hiding the guest triggers WebContents::WasHidden(). 828 // This test verifies that hiding the guest triggers WebContents::WasHidden().
813 IN_PROC_BROWSER_TEST_F(WebViewVisibilityTest, GuestVisibilityChanged) { 829 IN_PROC_BROWSER_TEST_P(WebViewVisibilityTest, GuestVisibilityChanged) {
814 LoadAppWithGuest("web_view/visibility_changed"); 830 LoadAppWithGuest("web_view/visibility_changed");
815 831
816 scoped_refptr<content::MessageLoopRunner> loop_runner( 832 scoped_refptr<content::MessageLoopRunner> loop_runner(
817 new content::MessageLoopRunner); 833 new content::MessageLoopRunner);
818 WebContentsHiddenObserver observer(GetGuestWebContents(), 834 WebContentsHiddenObserver observer(GetGuestWebContents(),
819 loop_runner->QuitClosure()); 835 loop_runner->QuitClosure());
820 836
821 // Handled in platform_apps/web_view/visibility_changed/main.js 837 // Handled in platform_apps/web_view/visibility_changed/main.js
822 SendMessageToEmbedder("hide-guest"); 838 SendMessageToEmbedder("hide-guest");
823 if (!observer.hidden_observed()) 839 if (!observer.hidden_observed())
824 loop_runner->Run(); 840 loop_runner->Run();
825 } 841 }
826 842
827 // This test verifies that hiding the embedder also hides the guest. 843 // This test verifies that hiding the embedder also hides the guest.
828 IN_PROC_BROWSER_TEST_F(WebViewVisibilityTest, EmbedderVisibilityChanged) { 844 IN_PROC_BROWSER_TEST_P(WebViewVisibilityTest, EmbedderVisibilityChanged) {
829 LoadAppWithGuest("web_view/visibility_changed"); 845 LoadAppWithGuest("web_view/visibility_changed");
830 846
831 scoped_refptr<content::MessageLoopRunner> loop_runner( 847 scoped_refptr<content::MessageLoopRunner> loop_runner(
832 new content::MessageLoopRunner); 848 new content::MessageLoopRunner);
833 WebContentsHiddenObserver observer(GetGuestWebContents(), 849 WebContentsHiddenObserver observer(GetGuestWebContents(),
834 loop_runner->QuitClosure()); 850 loop_runner->QuitClosure());
835 851
836 // Handled in platform_apps/web_view/visibility_changed/main.js 852 // Handled in platform_apps/web_view/visibility_changed/main.js
837 SendMessageToEmbedder("hide-embedder"); 853 SendMessageToEmbedder("hide-embedder");
838 if (!observer.hidden_observed()) 854 if (!observer.hidden_observed())
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 } 1323 }
1308 1324
1309 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestReloadAfterTerminate) { 1325 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestReloadAfterTerminate) {
1310 TestHelper("testReloadAfterTerminate", "web_view/shim", NO_TEST_SERVER); 1326 TestHelper("testReloadAfterTerminate", "web_view/shim", NO_TEST_SERVER);
1311 } 1327 }
1312 1328
1313 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestGetProcessId) { 1329 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestGetProcessId) {
1314 TestHelper("testGetProcessId", "web_view/shim", NO_TEST_SERVER); 1330 TestHelper("testGetProcessId", "web_view/shim", NO_TEST_SERVER);
1315 } 1331 }
1316 1332
1317 IN_PROC_BROWSER_TEST_F(WebViewVisibilityTest, Shim_TestHiddenBeforeNavigation) { 1333 IN_PROC_BROWSER_TEST_P(WebViewVisibilityTest, Shim_TestHiddenBeforeNavigation) {
1318 TestHelper("testHiddenBeforeNavigation", "web_view/shim", NO_TEST_SERVER); 1334 TestHelper("testHiddenBeforeNavigation", "web_view/shim", NO_TEST_SERVER);
1319 } 1335 }
1320 1336
1321 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestRemoveWebviewOnExit) { 1337 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestRemoveWebviewOnExit) {
1322 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. 1338 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages.
1323 1339
1324 // Launch the app and wait until it's ready to load a test. 1340 // Launch the app and wait until it's ready to load a test.
1325 LoadAndLaunchPlatformApp("web_view/shim", "Launched"); 1341 LoadAndLaunchPlatformApp("web_view/shim", "Launched");
1326 1342
1327 content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents(); 1343 content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents();
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after
3020 // 4 tasks expected. The order is arbitrary. 3036 // 4 tasks expected. The order is arbitrary.
3021 // Tab: about:blank, 3037 // Tab: about:blank,
3022 // Background Page: <webview> task manager test, 3038 // Background Page: <webview> task manager test,
3023 // App: <webview> task manager test, 3039 // App: <webview> task manager test,
3024 // Webview: WebViewed test content. 3040 // Webview: WebViewed test content.
3025 EXPECT_EQ(4U, task_manager.tasks().size()); 3041 EXPECT_EQ(4U, task_manager.tasks().size());
3026 EXPECT_TRUE(HasExpectedGuestTask(task_manager, guest_contents)); 3042 EXPECT_TRUE(HasExpectedGuestTask(task_manager, guest_contents));
3027 } 3043 }
3028 3044
3029 #endif // defined(ENABLE_TASK_MANAGER) 3045 #endif // defined(ENABLE_TASK_MANAGER)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698