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/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 // active_web_contents() is still the login window but the observer | 302 // active_web_contents() is still the login window but the observer |
303 // should be set up to observe the chromoting window because that is | 303 // should be set up to observe the chromoting window because that is |
304 // where we'll receive the message from the login window and reload the | 304 // where we'll receive the message from the login window and reload the |
305 // chromoting app. | 305 // chromoting app. |
306 content::WindowedNotificationObserver observer( | 306 content::WindowedNotificationObserver observer( |
307 content::NOTIFICATION_LOAD_STOP, | 307 content::NOTIFICATION_LOAD_STOP, |
308 base::Bind( | 308 base::Bind( |
309 &RemoteDesktopBrowserTest::IsAuthenticatedInWindow, | 309 &RemoteDesktopBrowserTest::IsAuthenticatedInWindow, |
310 browser()->tab_strip_model()->GetActiveWebContents())); | 310 browser()->tab_strip_model()->GetActiveWebContents())); |
311 | 311 |
312 ExecuteScript( | 312 // Click to Approve the web-app. |
313 "lso.approveButtonAction();" | 313 ClickOnControl("submit_approve_access"); |
314 "document.forms[\"connect-approve\"].submit();"); | |
315 | 314 |
316 observer.Wait(); | 315 observer.Wait(); |
317 | 316 |
318 // Popping the login window off the stack to return to the chromoting | 317 // Popping the login window off the stack to return to the chromoting |
319 // window. | 318 // window. |
320 web_contents_stack_.pop_back(); | 319 web_contents_stack_.pop_back(); |
321 } | 320 } |
322 | 321 |
323 ASSERT_TRUE(GetCurrentURL() == Chromoting_Main_URL()); | 322 ASSERT_TRUE(GetCurrentURL() == Chromoting_Main_URL()); |
324 | 323 |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
701 ASSERT_TRUE(dict_value->GetBoolean("succeeded", &succeeded)); | 700 ASSERT_TRUE(dict_value->GetBoolean("succeeded", &succeeded)); |
702 ASSERT_TRUE(dict_value->GetString("error_message", &error_message)); | 701 ASSERT_TRUE(dict_value->GetString("error_message", &error_message)); |
703 ASSERT_TRUE(dict_value->GetString("stack_trace", &stack_trace)); | 702 ASSERT_TRUE(dict_value->GetString("stack_trace", &stack_trace)); |
704 | 703 |
705 EXPECT_TRUE(succeeded) << error_message << "\n" << stack_trace; | 704 EXPECT_TRUE(succeeded) << error_message << "\n" << stack_trace; |
706 } | 705 } |
707 | 706 |
708 void RemoteDesktopBrowserTest::ClickOnControl(const std::string& name) { | 707 void RemoteDesktopBrowserTest::ClickOnControl(const std::string& name) { |
709 ASSERT_TRUE(HtmlElementVisible(name)); | 708 ASSERT_TRUE(HtmlElementVisible(name)); |
710 | 709 |
710 ConditionalTimeoutWaiter waiter( | |
711 base::TimeDelta::FromSeconds(5), | |
712 base::TimeDelta::FromMilliseconds(500), | |
713 base::Bind(&RemoteDesktopBrowserTest::IsEnabled, | |
714 active_web_contents(), | |
715 name)); | |
weitao
2014/09/09 23:36:37
style nit: the last two arguments can fit in the s
anandc1
2014/09/10 00:52:26
Done.
| |
716 EXPECT_TRUE(waiter.Wait()); | |
weitao
2014/09/09 23:36:37
This should be a ASSERT_TRUE because the there is
anandc1
2014/09/10 00:52:26
Done.
| |
717 | |
711 ExecuteScript("document.getElementById(\"" + name + "\").click();"); | 718 ExecuteScript("document.getElementById(\"" + name + "\").click();"); |
712 } | 719 } |
713 | 720 |
714 void RemoteDesktopBrowserTest::EnterPin(const std::string& pin, | 721 void RemoteDesktopBrowserTest::EnterPin(const std::string& pin, |
715 bool remember_pin) { | 722 bool remember_pin) { |
716 // Wait for the pin-form to be displayed. This can take a while. | 723 // Wait for the pin-form to be displayed. This can take a while. |
717 // We also need to dismiss the host-needs-update dialog if it comes up. | 724 // We also need to dismiss the host-needs-update dialog if it comes up. |
718 // TODO(weitaosu) 1: Instead of polling, can we register a callback to be | 725 // TODO(weitaosu) 1: Instead of polling, can we register a callback to be |
719 // called when the pin-form is ready? | 726 // called when the pin-form is ready? |
720 // TODO(weitaosu) 2: Instead of blindly dismiss the host-needs-update dialog, | 727 // TODO(weitaosu) 2: Instead of blindly dismiss the host-needs-update dialog, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
794 | 801 |
795 // static | 802 // static |
796 bool RemoteDesktopBrowserTest::IsHostActionComplete( | 803 bool RemoteDesktopBrowserTest::IsHostActionComplete( |
797 content::WebContents* client_web_content, | 804 content::WebContents* client_web_content, |
798 std::string host_action_var) { | 805 std::string host_action_var) { |
799 return ExecuteScriptAndExtractBool( | 806 return ExecuteScriptAndExtractBool( |
800 client_web_content, | 807 client_web_content, |
801 host_action_var); | 808 host_action_var); |
802 } | 809 } |
803 | 810 |
811 // static | |
812 bool RemoteDesktopBrowserTest::IsEnabled( | |
813 content::WebContents* client_web_content, | |
814 std::string element_name) { | |
815 return !ExecuteScriptAndExtractBool( | |
816 client_web_content, | |
817 "document.getElementById(\"" + element_name + "\").disabled"); | |
818 } | |
819 | |
804 } // namespace remoting | 820 } // namespace remoting |
OLD | NEW |