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::FromMilliseconds(5000), |
joedow
2016/01/06 16:33:52
Why base::TimeDelta::FromMilliseconds instead of u
alog1
2016/01/06 21:49:09
Done.
| |
590 "document.getElementById('" + element_id + "').parentNode.className"); | 590 base::Bind(&RemoteDesktopBrowserTest::IsHostOnline, this, host_id)); |
joedow
2016/01/06 16:33:52
You should declare the ownership of the this point
alog1
2016/01/06 21:49:09
Done.
| |
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(std::string host_id) { | |
joedow
2016/01/06 16:33:52
host_id should be passed as a const ref.
alog1
2016/01/06 21:49:09
Done.
| |
820 bool refresh_host_list = | |
821 ExecuteScriptAndExtractBool("remoting.hostList.refreshAndDisplay()"); | |
822 | |
823 if (!refresh_host_list) { | |
824 return false; | |
825 } | |
joedow
2016/01/06 16:33:52
Add a newline here to make this more readable.
Al
alog1
2016/01/06 21:49:09
Done.
| |
826 std::string element_id = "host_" + host_id; | |
827 // Verify the host is online. | |
joedow
2016/01/06 16:33:52
I think comment should be moved up one line so the
alog1
2016/01/06 21:49:09
Done.
| |
828 std::string host_div_class = ExecuteScriptAndExtractString( | |
829 "document.getElementById('" + element_id + "').parentNode.className"); | |
830 | |
831 return (std::string::npos != host_div_class.find("host-online")); | |
832 } | |
833 | |
819 bool RemoteDesktopBrowserTest::IsLocalHostReady() { | 834 bool RemoteDesktopBrowserTest::IsLocalHostReady() { |
820 // TODO(weitaosu): Instead of polling, can we register a callback to | 835 // TODO(weitaosu): Instead of polling, can we register a callback to |
821 // remoting.hostList.setLocalHost_? | 836 // remoting.hostList.setLocalHost_? |
822 return ExecuteScriptAndExtractBool( | 837 return ExecuteScriptAndExtractBool( |
823 "remoting.hostList.localHostSection_.host_ != null"); | 838 "remoting.hostList.localHostSection_.host_ != null"); |
824 } | 839 } |
825 | 840 |
826 bool RemoteDesktopBrowserTest::IsHostListReady() { | 841 bool RemoteDesktopBrowserTest::IsHostListReady() { |
827 // Wait until hostList is not null. | 842 // Wait until hostList is not null. |
828 // The connect-to-host tests are run on the waterfall using a new profile-dir. | 843 // 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 | 937 |
923 ConditionalTimeoutWaiter homeWaiter( | 938 ConditionalTimeoutWaiter homeWaiter( |
924 base::TimeDelta::FromSeconds(5), | 939 base::TimeDelta::FromSeconds(5), |
925 base::TimeDelta::FromMilliseconds(500), | 940 base::TimeDelta::FromMilliseconds(500), |
926 base::Bind(&RemoteDesktopBrowserTest::IsAppModeEqualTo, | 941 base::Bind(&RemoteDesktopBrowserTest::IsAppModeEqualTo, |
927 this, "remoting.AppMode.HOME")); | 942 this, "remoting.AppMode.HOME")); |
928 EXPECT_TRUE(homeWaiter.Wait()); | 943 EXPECT_TRUE(homeWaiter.Wait()); |
929 } | 944 } |
930 | 945 |
931 } // namespace remoting | 946 } // namespace remoting |
OLD | NEW |