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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
700 ASSERT_TRUE(dict_value->GetBoolean("succeeded", &succeeded)); | 700 ASSERT_TRUE(dict_value->GetBoolean("succeeded", &succeeded)); |
701 ASSERT_TRUE(dict_value->GetString("error_message", &error_message)); | 701 ASSERT_TRUE(dict_value->GetString("error_message", &error_message)); |
702 ASSERT_TRUE(dict_value->GetString("stack_trace", &stack_trace)); | 702 ASSERT_TRUE(dict_value->GetString("stack_trace", &stack_trace)); |
703 | 703 |
704 EXPECT_TRUE(succeeded) << error_message << "\n" << stack_trace; | 704 EXPECT_TRUE(succeeded) << error_message << "\n" << stack_trace; |
705 } | 705 } |
706 | 706 |
707 void RemoteDesktopBrowserTest::ClickOnControl(const std::string& name) { | 707 void RemoteDesktopBrowserTest::ClickOnControl(const std::string& name) { |
708 ASSERT_TRUE(HtmlElementVisible(name)); | 708 ASSERT_TRUE(HtmlElementVisible(name)); |
709 | 709 |
710 ConditionalTimeoutWaiter waiter( | 710 std::string has_disabled_attribute = |
711 base::TimeDelta::FromSeconds(5), | 711 "document.getElementById('" + name + "').hasAttribute('disabled')"; |
712 base::TimeDelta::FromMilliseconds(500), | 712 |
713 base::Bind(&RemoteDesktopBrowserTest::IsEnabled, | 713 if (ExecuteScriptAndExtractBool(active_web_contents(), |
714 active_web_contents(), name)); | 714 has_disabled_attribute)) { |
Jamie
2014/09/19 22:37:23
Nit: Indent the second and subsequent parameters t
anandc
2014/09/19 22:45:05
Done.
| |
715 ASSERT_TRUE(waiter.Wait()); | 715 // This element has a disabled attribute. Wait for it become enabled. |
716 ConditionalTimeoutWaiter waiter( | |
717 base::TimeDelta::FromSeconds(5), | |
718 base::TimeDelta::FromMilliseconds(500), | |
719 base::Bind(&RemoteDesktopBrowserTest::IsEnabled, | |
720 active_web_contents(), name)); | |
721 ASSERT_TRUE(waiter.Wait()); | |
722 } | |
716 | 723 |
717 ExecuteScript("document.getElementById(\"" + name + "\").click();"); | 724 ExecuteScript("document.getElementById(\"" + name + "\").click();"); |
718 } | 725 } |
719 | 726 |
720 void RemoteDesktopBrowserTest::EnterPin(const std::string& pin, | 727 void RemoteDesktopBrowserTest::EnterPin(const std::string& pin, |
721 bool remember_pin) { | 728 bool remember_pin) { |
722 // Wait for the pin-form to be displayed. This can take a while. | 729 // Wait for the pin-form to be displayed. This can take a while. |
723 // We also need to dismiss the host-needs-update dialog if it comes up. | 730 // We also need to dismiss the host-needs-update dialog if it comes up. |
724 // TODO(weitaosu) 1: Instead of polling, can we register a callback to be | 731 // TODO(weitaosu) 1: Instead of polling, can we register a callback to be |
725 // called when the pin-form is ready? | 732 // called when the pin-form is ready? |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
810 // static | 817 // static |
811 bool RemoteDesktopBrowserTest::IsEnabled( | 818 bool RemoteDesktopBrowserTest::IsEnabled( |
812 content::WebContents* client_web_content, | 819 content::WebContents* client_web_content, |
813 const std::string& element_name) { | 820 const std::string& element_name) { |
814 return !ExecuteScriptAndExtractBool( | 821 return !ExecuteScriptAndExtractBool( |
815 client_web_content, | 822 client_web_content, |
816 "document.getElementById(\"" + element_name + "\").disabled"); | 823 "document.getElementById(\"" + element_name + "\").disabled"); |
817 } | 824 } |
818 | 825 |
819 } // namespace remoting | 826 } // namespace remoting |
OLD | NEW |