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 ConditionalTimeoutWaiter hostOnlineWaiter( | 590 ConditionalTimeoutWaiter hostOnlineWaiter( |
joedow
2016/01/20 22:23:06
You may want to add a comment about what this code
alog1
2016/01/20 22:39:54
Done.
| |
591 base::TimeDelta::FromSeconds(30), base::TimeDelta::FromSeconds(5), | 591 base::TimeDelta::FromSeconds(60), base::TimeDelta::FromSeconds(20), |
592 base::Bind(&RemoteDesktopBrowserTest::IsHostOnline, | 592 base::Bind(&RemoteDesktopBrowserTest::IsHostOnline, |
593 base::Unretained(this), host_id)); | 593 base::Unretained(this), host_id)); |
594 EXPECT_TRUE(hostOnlineWaiter.Wait()); | 594 EXPECT_TRUE(hostOnlineWaiter.Wait()); |
595 | 595 |
596 ClickOnControl(element_id); | 596 ClickOnControl(element_id); |
597 | 597 |
598 // Enter the pin # passed in from the command line. | 598 // Enter the pin # passed in from the command line. |
599 EnterPin(me2me_pin(), remember_pin); | 599 EnterPin(me2me_pin(), remember_pin); |
600 | 600 |
601 WaitForConnection(); | 601 WaitForConnection(); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
813 base::Bind(&RemoteDesktopBrowserTest::IsSessionConnected, this)); | 813 base::Bind(&RemoteDesktopBrowserTest::IsSessionConnected, this)); |
814 EXPECT_TRUE(waiter.Wait()); | 814 EXPECT_TRUE(waiter.Wait()); |
815 | 815 |
816 // The client is not yet ready to take input when the session state becomes | 816 // 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. | 817 // 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. | 818 // TODO(weitaosu): Find a way to detect when the client is truly ready. |
819 TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait(); | 819 TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait(); |
820 } | 820 } |
821 | 821 |
822 bool RemoteDesktopBrowserTest::IsHostOnline(const std::string& host_id) { | 822 bool RemoteDesktopBrowserTest::IsHostOnline(const std::string& host_id) { |
823 bool refresh_host_list = | |
824 ExecuteScriptAndExtractBool("remoting.hostList.refreshAndDisplay()"); | |
825 | 823 |
826 if (!refresh_host_list) { | 824 ExecuteScript("remoting.hostList.refreshAndDisplay()"); |
827 return false; | |
828 } | |
829 | 825 |
830 // Verify the host is online. | 826 // Verify the host is online. |
831 std::string element_id = "host_" + host_id; | 827 std::string element_id = "host_" + host_id; |
832 std::string host_div_class = ExecuteScriptAndExtractString( | 828 std::string host_div_class = ExecuteScriptAndExtractString( |
833 "document.getElementById('" + element_id + "').parentNode.className"); | 829 "document.getElementById('" + element_id + "').parentNode.className"); |
834 | 830 |
835 return (std::string::npos != host_div_class.find("host-online")); | 831 return (std::string::npos != host_div_class.find("host-online")); |
836 } | 832 } |
837 | 833 |
838 bool RemoteDesktopBrowserTest::IsLocalHostReady() { | 834 bool RemoteDesktopBrowserTest::IsLocalHostReady() { |
839 // TODO(weitaosu): Instead of polling, can we register a callback to | 835 // TODO(weitaosu): Instead of polling, can we register a callback to |
840 // remoting.hostList.setLocalHost_? | 836 // remoting.hostList.setLocalHost_? |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
941 | 937 |
942 ConditionalTimeoutWaiter homeWaiter( | 938 ConditionalTimeoutWaiter homeWaiter( |
943 base::TimeDelta::FromSeconds(5), | 939 base::TimeDelta::FromSeconds(5), |
944 base::TimeDelta::FromMilliseconds(500), | 940 base::TimeDelta::FromMilliseconds(500), |
945 base::Bind(&RemoteDesktopBrowserTest::IsAppModeEqualTo, | 941 base::Bind(&RemoteDesktopBrowserTest::IsAppModeEqualTo, |
946 this, "remoting.AppMode.HOME")); | 942 this, "remoting.AppMode.HOME")); |
947 EXPECT_TRUE(homeWaiter.Wait()); | 943 EXPECT_TRUE(homeWaiter.Wait()); |
948 } | 944 } |
949 | 945 |
950 } // namespace remoting | 946 } // namespace remoting |
OLD | NEW |