Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 protected: | 738 protected: |
| 739 void SetUpCommandLine(base::CommandLine* command_line) override { | 739 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 740 WebViewTest::SetUpCommandLine(command_line); | 740 WebViewTest::SetUpCommandLine(command_line); |
| 741 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, | 741 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, |
| 742 base::StringPrintf("%f", scale())); | 742 base::StringPrintf("%f", scale())); |
| 743 } | 743 } |
| 744 | 744 |
| 745 static float scale() { return 2.0f; } | 745 static float scale() { return 2.0f; } |
| 746 }; | 746 }; |
| 747 | 747 |
| 748 class WebContentsAudioMutedObserver : public content::WebContentsObserver { | |
| 749 public: | |
| 750 WebContentsAudioMutedObserver(content::WebContents* web_contents, | |
| 751 const base::Closure& muted_callback) | |
| 752 : WebContentsObserver(web_contents), | |
| 753 muted_callback_(muted_callback), | |
| 754 muting_update_observed_(false) { | |
| 755 } | |
| 756 | |
| 757 // WebContentsObserver. | |
| 758 void DidUpdateAudioMutingState(bool muted) override { | |
| 759 muting_update_observed_ = true; | |
| 760 muted_callback_.Run(); | |
| 761 } | |
| 762 | |
| 763 bool muting_update_observed() { return muting_update_observed_; } | |
| 764 | |
| 765 private: | |
| 766 base::Closure muted_callback_; | |
| 767 bool muting_update_observed_; | |
| 768 | |
| 769 DISALLOW_COPY_AND_ASSIGN(WebContentsAudioMutedObserver); | |
| 770 }; | |
| 771 | |
| 772 IN_PROC_BROWSER_TEST_F(WebViewTest, AudioMutesWhileAttached) { | |
| 773 LoadAppWithGuest("web_view/simple"); | |
| 774 | |
| 775 content::WebContents* embedder = GetEmbedderWebContents(); | |
| 776 content::WebContents* guest = GetGuestWebContents(); | |
| 777 | |
| 778 EXPECT_FALSE(embedder->IsAudioMuted()); | |
| 779 EXPECT_FALSE(guest->IsAudioMuted()); | |
| 780 | |
| 781 embedder->SetAudioMuted(true); | |
| 782 EXPECT_TRUE(embedder->IsAudioMuted()); | |
| 783 EXPECT_TRUE(guest->IsAudioMuted()); | |
| 784 | |
| 785 embedder->SetAudioMuted(false); | |
| 786 EXPECT_FALSE(embedder->IsAudioMuted()); | |
| 787 EXPECT_FALSE(guest->IsAudioMuted()); | |
|
Charlie Reis
2016/01/06 22:13:51
Is it possible to mute a guest without muting the
wjmaclean
2016/01/06 22:36:09
At present there is no pathway to mute a guest dir
Charlie Reis
2016/01/07 00:11:02
Acknowledged.
| |
| 788 } | |
| 789 | |
| 790 IN_PROC_BROWSER_TEST_F(WebViewTest, AudioMutesOnAttach) { | |
| 791 LoadAndLaunchPlatformApp("web_view/app_creates_webview", | |
| 792 "WebViewTest.LAUNCHED"); | |
| 793 content::WebContents* embedder = GetEmbedderWebContents(); | |
| 794 embedder->SetAudioMuted(true); | |
| 795 EXPECT_TRUE(embedder->IsAudioMuted()); | |
| 796 | |
| 797 SendMessageToEmbedder("create-guest"); | |
| 798 content::WebContents* guest = | |
| 799 GetGuestViewManager()->WaitForSingleGuestCreated(); | |
| 800 | |
| 801 EXPECT_TRUE(embedder->IsAudioMuted()); | |
| 802 scoped_refptr<content::MessageLoopRunner> loop_runner( | |
| 803 new content::MessageLoopRunner); | |
| 804 WebContentsAudioMutedObserver observer(guest, loop_runner->QuitClosure()); | |
| 805 // 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. | |
| 807 if (!guest->IsAudioMuted() && !observer.muting_update_observed()) | |
|
Charlie Reis
2016/01/06 22:13:51
observer.muting_update_observed() can't be true he
wjmaclean
2016/01/06 22:36:09
I suspect you're right, but I left the check in fo
| |
| 808 loop_runner->Run(); | |
|
Charlie Reis
2016/01/06 22:13:51
nit: Most of the test observer classes I'm familia
wjmaclean
2016/01/06 22:36:09
Sure, I can do that.
| |
| 809 EXPECT_TRUE(guest->IsAudioMuted()); | |
| 810 } | |
| 811 | |
| 748 // This test verifies that hiding the guest triggers WebContents::WasHidden(). | 812 // This test verifies that hiding the guest triggers WebContents::WasHidden(). |
| 749 IN_PROC_BROWSER_TEST_F(WebViewVisibilityTest, GuestVisibilityChanged) { | 813 IN_PROC_BROWSER_TEST_F(WebViewVisibilityTest, GuestVisibilityChanged) { |
| 750 LoadAppWithGuest("web_view/visibility_changed"); | 814 LoadAppWithGuest("web_view/visibility_changed"); |
| 751 | 815 |
| 752 scoped_refptr<content::MessageLoopRunner> loop_runner( | 816 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 753 new content::MessageLoopRunner); | 817 new content::MessageLoopRunner); |
| 754 WebContentsHiddenObserver observer(GetGuestWebContents(), | 818 WebContentsHiddenObserver observer(GetGuestWebContents(), |
| 755 loop_runner->QuitClosure()); | 819 loop_runner->QuitClosure()); |
| 756 | 820 |
| 757 // Handled in platform_apps/web_view/visibility_changed/main.js | 821 // Handled in platform_apps/web_view/visibility_changed/main.js |
| (...skipping 2197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2955 // 4 tasks expected. The order is arbitrary. | 3019 // 4 tasks expected. The order is arbitrary. |
| 2956 // Tab: about:blank, | 3020 // Tab: about:blank, |
| 2957 // Background Page: <webview> task manager test, | 3021 // Background Page: <webview> task manager test, |
| 2958 // App: <webview> task manager test, | 3022 // App: <webview> task manager test, |
| 2959 // Webview: WebViewed test content. | 3023 // Webview: WebViewed test content. |
| 2960 EXPECT_EQ(4U, task_manager.tasks().size()); | 3024 EXPECT_EQ(4U, task_manager.tasks().size()); |
| 2961 EXPECT_TRUE(HasExpectedGuestTask(task_manager, guest_contents)); | 3025 EXPECT_TRUE(HasExpectedGuestTask(task_manager, guest_contents)); |
| 2962 } | 3026 } |
| 2963 | 3027 |
| 2964 #endif // defined(ENABLE_TASK_MANAGER) | 3028 #endif // defined(ENABLE_TASK_MANAGER) |
| OLD | NEW |