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/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 base::TimeDelta::FromMilliseconds(500), | 578 base::TimeDelta::FromMilliseconds(500), |
579 base::Bind(&RemoteDesktopBrowserTest::IsHostListReady, this)); | 579 base::Bind(&RemoteDesktopBrowserTest::IsHostListReady, this)); |
580 EXPECT_TRUE(waiter.Wait()); | 580 EXPECT_TRUE(waiter.Wait()); |
581 | 581 |
582 std::string host_id = ExecuteScriptAndExtractString( | 582 std::string host_id = ExecuteScriptAndExtractString( |
583 "remoting.hostList.getHostIdForName('" + host_name + "')"); | 583 "remoting.hostList.getHostIdForName('" + host_name + "')"); |
584 | 584 |
585 EXPECT_FALSE(host_id.empty()); | 585 EXPECT_FALSE(host_id.empty()); |
586 std::string element_id = "host_" + host_id; | 586 std::string element_id = "host_" + host_id; |
587 | 587 |
588 // Verify the host is online. | 588 ConditionalTimeoutWaiter hostOnlineWaiter( |
589 std::string host_div_class = ExecuteScriptAndExtractString( | 589 base::TimeDelta::FromSeconds(30), base::TimeDelta::FromSeconds(5), |
590 "document.getElementById('" + element_id + "').parentNode.className"); | 590 base::Bind(&RemoteDesktopBrowserTest::IsHostOnline, |
591 EXPECT_NE(std::string::npos, host_div_class.find("host-online")); | 591 base::Unretained(this), host_id)); |
| 592 EXPECT_TRUE(hostOnlineWaiter.Wait()); |
592 | 593 |
593 ClickOnControl(element_id); | 594 ClickOnControl(element_id); |
594 | 595 |
595 // Enter the pin # passed in from the command line. | 596 // Enter the pin # passed in from the command line. |
596 EnterPin(me2me_pin(), remember_pin); | 597 EnterPin(me2me_pin(), remember_pin); |
597 | 598 |
598 WaitForConnection(); | 599 WaitForConnection(); |
599 } | 600 } |
600 | 601 |
601 void RemoteDesktopBrowserTest::EnableDNSLookupForThisTest( | 602 void RemoteDesktopBrowserTest::EnableDNSLookupForThisTest( |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 base::TimeDelta::FromSeconds(1), | 810 base::TimeDelta::FromSeconds(1), |
810 base::Bind(&RemoteDesktopBrowserTest::IsSessionConnected, this)); | 811 base::Bind(&RemoteDesktopBrowserTest::IsSessionConnected, this)); |
811 EXPECT_TRUE(waiter.Wait()); | 812 EXPECT_TRUE(waiter.Wait()); |
812 | 813 |
813 // The client is not yet ready to take input when the session state becomes | 814 // The client is not yet ready to take input when the session state becomes |
814 // CONNECTED. Wait for 2 seconds for the client to become ready. | 815 // CONNECTED. Wait for 2 seconds for the client to become ready. |
815 // TODO(weitaosu): Find a way to detect when the client is truly ready. | 816 // TODO(weitaosu): Find a way to detect when the client is truly ready. |
816 TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait(); | 817 TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait(); |
817 } | 818 } |
818 | 819 |
| 820 bool RemoteDesktopBrowserTest::IsHostOnline(const std::string& host_id) { |
| 821 bool refresh_host_list = |
| 822 ExecuteScriptAndExtractBool("remoting.hostList.refreshAndDisplay()"); |
| 823 |
| 824 if (!refresh_host_list) { |
| 825 return false; |
| 826 } |
| 827 |
| 828 // Verify the host is online. |
| 829 std::string element_id = "host_" + host_id; |
| 830 std::string host_div_class = ExecuteScriptAndExtractString( |
| 831 "document.getElementById('" + element_id + "').parentNode.className"); |
| 832 |
| 833 return (std::string::npos != host_div_class.find("host-online")); |
| 834 } |
| 835 |
819 bool RemoteDesktopBrowserTest::IsLocalHostReady() { | 836 bool RemoteDesktopBrowserTest::IsLocalHostReady() { |
820 // TODO(weitaosu): Instead of polling, can we register a callback to | 837 // TODO(weitaosu): Instead of polling, can we register a callback to |
821 // remoting.hostList.setLocalHost_? | 838 // remoting.hostList.setLocalHost_? |
822 return ExecuteScriptAndExtractBool( | 839 return ExecuteScriptAndExtractBool( |
823 "remoting.hostList.localHostSection_.host_ != null"); | 840 "remoting.hostList.localHostSection_.host_ != null"); |
824 } | 841 } |
825 | 842 |
826 bool RemoteDesktopBrowserTest::IsHostListReady() { | 843 bool RemoteDesktopBrowserTest::IsHostListReady() { |
827 // Wait until hostList is not null. | 844 // Wait until hostList is not null. |
828 // The connect-to-host tests are run on the waterfall using a new profile-dir. | 845 // The connect-to-host tests are run on the waterfall using a new profile-dir. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 | 939 |
923 ConditionalTimeoutWaiter homeWaiter( | 940 ConditionalTimeoutWaiter homeWaiter( |
924 base::TimeDelta::FromSeconds(5), | 941 base::TimeDelta::FromSeconds(5), |
925 base::TimeDelta::FromMilliseconds(500), | 942 base::TimeDelta::FromMilliseconds(500), |
926 base::Bind(&RemoteDesktopBrowserTest::IsAppModeEqualTo, | 943 base::Bind(&RemoteDesktopBrowserTest::IsAppModeEqualTo, |
927 this, "remoting.AppMode.HOME")); | 944 this, "remoting.AppMode.HOME")); |
928 EXPECT_TRUE(homeWaiter.Wait()); | 945 EXPECT_TRUE(homeWaiter.Wait()); |
929 } | 946 } |
930 | 947 |
931 } // namespace remoting | 948 } // namespace remoting |
OLD | NEW |