Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: chrome/test/remoting/remote_desktop_browsertest.cc

Issue 1554313002: Adding changes to Remote_Desktop_BrowserTest ConnecToRemoteHost to verify if the remote host is onl… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/remoting/remote_desktop_browsertest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 hostReadyWaiter(
anandc1 2016/01/06 01:29:51 hostOnlineWaiter?
589 std::string host_div_class = ExecuteScriptAndExtractString( 589 base::TimeDelta::FromSeconds(30), base::TimeDelta::FromMilliseconds(5000),
590 "document.getElementById('" + element_id + "').parentNode.className"); 590 base::Bind(&RemoteDesktopBrowserTest::IsHostOnline, this, element_id));
591 EXPECT_NE(std::string::npos, host_div_class.find("host-online")); 591 EXPECT_TRUE(hostReadyWaiter.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
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 element_id) {
anandc1 2016/01/06 01:29:51 It would be clearer to pass in the hostID to this
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 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
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
OLDNEW
« no previous file with comments | « chrome/test/remoting/remote_desktop_browsertest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698