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