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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 base::TimeDelta::FromMilliseconds(500), | 580 base::TimeDelta::FromMilliseconds(500), |
581 base::Bind(&RemoteDesktopBrowserTest::IsHostListReady, this)); | 581 base::Bind(&RemoteDesktopBrowserTest::IsHostListReady, this)); |
582 EXPECT_TRUE(waiter.Wait()); | 582 EXPECT_TRUE(waiter.Wait()); |
583 | 583 |
584 std::string host_id = ExecuteScriptAndExtractString( | 584 std::string host_id = ExecuteScriptAndExtractString( |
585 "remoting.hostList.getHostIdForName('" + host_name + "')"); | 585 "remoting.hostList.getHostIdForName('" + host_name + "')"); |
586 | 586 |
587 EXPECT_FALSE(host_id.empty()); | 587 EXPECT_FALSE(host_id.empty()); |
588 std::string element_id = "host_" + host_id; | 588 std::string element_id = "host_" + host_id; |
589 | 589 |
| 590 // Wait for the hosts to be online. Try 3 times each spanning 20 seconds |
| 591 // successively for 60 seconds. |
590 ConditionalTimeoutWaiter hostOnlineWaiter( | 592 ConditionalTimeoutWaiter hostOnlineWaiter( |
591 base::TimeDelta::FromSeconds(30), base::TimeDelta::FromSeconds(5), | 593 base::TimeDelta::FromSeconds(60), base::TimeDelta::FromSeconds(20), |
592 base::Bind(&RemoteDesktopBrowserTest::IsHostOnline, | 594 base::Bind(&RemoteDesktopBrowserTest::IsHostOnline, |
593 base::Unretained(this), host_id)); | 595 base::Unretained(this), host_id)); |
594 EXPECT_TRUE(hostOnlineWaiter.Wait()); | 596 EXPECT_TRUE(hostOnlineWaiter.Wait()); |
595 | 597 |
596 ClickOnControl(element_id); | 598 ClickOnControl(element_id); |
597 | 599 |
598 // Enter the pin # passed in from the command line. | 600 // Enter the pin # passed in from the command line. |
599 EnterPin(me2me_pin(), remember_pin); | 601 EnterPin(me2me_pin(), remember_pin); |
600 | 602 |
601 WaitForConnection(); | 603 WaitForConnection(); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 base::Bind(&RemoteDesktopBrowserTest::IsSessionConnected, this)); | 815 base::Bind(&RemoteDesktopBrowserTest::IsSessionConnected, this)); |
814 EXPECT_TRUE(waiter.Wait()); | 816 EXPECT_TRUE(waiter.Wait()); |
815 | 817 |
816 // The client is not yet ready to take input when the session state becomes | 818 // The client is not yet ready to take input when the session state becomes |
817 // CONNECTED. Wait for 2 seconds for the client to become ready. | 819 // CONNECTED. Wait for 2 seconds for the client to become ready. |
818 // TODO(weitaosu): Find a way to detect when the client is truly ready. | 820 // TODO(weitaosu): Find a way to detect when the client is truly ready. |
819 TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait(); | 821 TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait(); |
820 } | 822 } |
821 | 823 |
822 bool RemoteDesktopBrowserTest::IsHostOnline(const std::string& host_id) { | 824 bool RemoteDesktopBrowserTest::IsHostOnline(const std::string& host_id) { |
823 bool refresh_host_list = | |
824 ExecuteScriptAndExtractBool("remoting.hostList.refreshAndDisplay()"); | |
825 | 825 |
826 if (!refresh_host_list) { | 826 ExecuteScript("remoting.hostList.refreshAndDisplay()"); |
827 return false; | |
828 } | |
829 | 827 |
830 // Verify the host is online. | 828 // Verify the host is online. |
831 std::string element_id = "host_" + host_id; | 829 std::string element_id = "host_" + host_id; |
832 std::string host_div_class = ExecuteScriptAndExtractString( | 830 std::string host_div_class = ExecuteScriptAndExtractString( |
833 "document.getElementById('" + element_id + "').parentNode.className"); | 831 "document.getElementById('" + element_id + "').parentNode.className"); |
834 | 832 |
835 return (std::string::npos != host_div_class.find("host-online")); | 833 return (std::string::npos != host_div_class.find("host-online")); |
836 } | 834 } |
837 | 835 |
838 bool RemoteDesktopBrowserTest::IsLocalHostReady() { | 836 bool RemoteDesktopBrowserTest::IsLocalHostReady() { |
839 // TODO(weitaosu): Instead of polling, can we register a callback to | 837 // TODO(weitaosu): Instead of polling, can we register a callback to |
840 // remoting.hostList.setLocalHost_? | 838 // remoting.hostList.setLocalHost_? |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 | 939 |
942 ConditionalTimeoutWaiter homeWaiter( | 940 ConditionalTimeoutWaiter homeWaiter( |
943 base::TimeDelta::FromSeconds(5), | 941 base::TimeDelta::FromSeconds(5), |
944 base::TimeDelta::FromMilliseconds(500), | 942 base::TimeDelta::FromMilliseconds(500), |
945 base::Bind(&RemoteDesktopBrowserTest::IsAppModeEqualTo, | 943 base::Bind(&RemoteDesktopBrowserTest::IsAppModeEqualTo, |
946 this, "remoting.AppMode.HOME")); | 944 this, "remoting.AppMode.HOME")); |
947 EXPECT_TRUE(homeWaiter.Wait()); | 945 EXPECT_TRUE(homeWaiter.Wait()); |
948 } | 946 } |
949 | 947 |
950 } // namespace remoting | 948 } // namespace remoting |
OLD | NEW |