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 "chrome/test/remoting/remote_desktop_browsertest.h" | 5 #include "chrome/test/remoting/remote_desktop_browsertest.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 void RemoteDesktopBrowserTest::EnterPin(const std::string& pin, | 714 void RemoteDesktopBrowserTest::EnterPin(const std::string& pin, |
715 bool remember_pin) { | 715 bool remember_pin) { |
716 // Wait for the pin-form to be displayed. This can take a while. | 716 // Wait for the pin-form to be displayed. This can take a while. |
717 // We also need to dismiss the host-needs-update dialog if it comes up. | 717 // We also need to dismiss the host-needs-update dialog if it comes up. |
718 // TODO(weitaosu) 1: Instead of polling, can we register a callback to be | 718 // TODO(weitaosu) 1: Instead of polling, can we register a callback to be |
719 // called when the pin-form is ready? | 719 // called when the pin-form is ready? |
720 // TODO(weitaosu) 2: Instead of blindly dismiss the host-needs-update dialog, | 720 // TODO(weitaosu) 2: Instead of blindly dismiss the host-needs-update dialog, |
721 // we should verify that it only pops up at the right circumstance. That | 721 // we should verify that it only pops up at the right circumstance. That |
722 // probably belongs in a separate test case though. | 722 // probably belongs in a separate test case though. |
723 ConditionalTimeoutWaiter waiter( | 723 ConditionalTimeoutWaiter waiter( |
724 base::TimeDelta::FromSeconds(5), | 724 base::TimeDelta::FromSeconds(30), |
725 base::TimeDelta::FromSeconds(1), | 725 base::TimeDelta::FromSeconds(1), |
726 base::Bind(&RemoteDesktopBrowserTest::IsPinFormVisible, this)); | 726 base::Bind(&RemoteDesktopBrowserTest::IsPinFormVisible, this)); |
727 EXPECT_TRUE(waiter.Wait()); | 727 EXPECT_TRUE(waiter.Wait()); |
728 | 728 |
729 ExecuteScript( | 729 ExecuteScript( |
730 "document.getElementById(\"pin-entry\").value = \"" + pin + "\";"); | 730 "document.getElementById(\"pin-entry\").value = \"" + pin + "\";"); |
731 | 731 |
732 if (remember_pin) { | 732 if (remember_pin) { |
733 EXPECT_TRUE(HtmlElementVisible("remember-pin")); | 733 EXPECT_TRUE(HtmlElementVisible("remember-pin")); |
734 EXPECT_FALSE(ExecuteScriptAndExtractBool( | 734 EXPECT_FALSE(ExecuteScriptAndExtractBool( |
735 "document.getElementById('remember-pin-checkbox').checked")); | 735 "document.getElementById('remember-pin-checkbox').checked")); |
736 ClickOnControl("remember-pin"); | 736 ClickOnControl("remember-pin"); |
737 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 737 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
738 "document.getElementById('remember-pin-checkbox').checked")); | 738 "document.getElementById('remember-pin-checkbox').checked")); |
739 } | 739 } |
740 | 740 |
741 ClickOnControl("pin-connect-button"); | 741 ClickOnControl("pin-connect-button"); |
742 } | 742 } |
743 | 743 |
744 void RemoteDesktopBrowserTest::WaitForConnection() { | 744 void RemoteDesktopBrowserTest::WaitForConnection() { |
745 // Wait until the client has connected to the server. | 745 // Wait until the client has connected to the server. |
746 // This can take a while. | 746 // This can take a while. |
747 // TODO(weitaosu): Instead of polling, can we register a callback to | 747 // TODO(weitaosu): Instead of polling, can we register a callback to |
748 // remoting.clientSession.onStageChange_? | 748 // remoting.clientSession.onStageChange_? |
749 ConditionalTimeoutWaiter waiter( | 749 ConditionalTimeoutWaiter waiter( |
750 base::TimeDelta::FromSeconds(4), | 750 base::TimeDelta::FromSeconds(30), |
751 base::TimeDelta::FromSeconds(1), | 751 base::TimeDelta::FromSeconds(1), |
752 base::Bind(&RemoteDesktopBrowserTest::IsSessionConnected, this)); | 752 base::Bind(&RemoteDesktopBrowserTest::IsSessionConnected, this)); |
753 EXPECT_TRUE(waiter.Wait()); | 753 EXPECT_TRUE(waiter.Wait()); |
754 | 754 |
755 // The client is not yet ready to take input when the session state becomes | 755 // The client is not yet ready to take input when the session state becomes |
756 // CONNECTED. Wait for 2 seconds for the client to become ready. | 756 // CONNECTED. Wait for 2 seconds for the client to become ready. |
757 // TODO(weitaosu): Find a way to detect when the client is truly ready. | 757 // TODO(weitaosu): Find a way to detect when the client is truly ready. |
758 TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait(); | 758 TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait(); |
759 } | 759 } |
760 | 760 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 // static | 795 // static |
796 bool RemoteDesktopBrowserTest::IsHostActionComplete( | 796 bool RemoteDesktopBrowserTest::IsHostActionComplete( |
797 content::WebContents* client_web_content, | 797 content::WebContents* client_web_content, |
798 std::string host_action_var) { | 798 std::string host_action_var) { |
799 return ExecuteScriptAndExtractBool( | 799 return ExecuteScriptAndExtractBool( |
800 client_web_content, | 800 client_web_content, |
801 host_action_var); | 801 host_action_var); |
802 } | 802 } |
803 | 803 |
804 } // namespace remoting | 804 } // namespace remoting |
OLD | NEW |