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/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 EXPECT_TRUE(HtmlElementVisible("me2me-content")); | 343 EXPECT_TRUE(HtmlElementVisible("me2me-content")); |
| 344 EXPECT_FALSE(HtmlElementVisible("me2me-first-run")); | 344 EXPECT_FALSE(HtmlElementVisible("me2me-first-run")); |
| 345 } | 345 } |
| 346 | 346 |
| 347 void RemoteDesktopBrowserTest::DisconnectMe2Me() { | 347 void RemoteDesktopBrowserTest::DisconnectMe2Me() { |
| 348 // The chromoting extension should be installed. | 348 // The chromoting extension should be installed. |
| 349 ASSERT_TRUE(extension_); | 349 ASSERT_TRUE(extension_); |
| 350 | 350 |
| 351 ASSERT_TRUE(RemoteDesktopBrowserTest::IsSessionConnected()); | 351 ASSERT_TRUE(RemoteDesktopBrowserTest::IsSessionConnected()); |
| 352 | 352 |
| 353 // Assuming the toolbar-stub is always enabled, click on it. | |
|
Jamie
2014/09/19 20:29:45
This comment is no longer needed.
anandc
2014/09/19 22:34:26
Done.
| |
| 353 ClickOnControl("toolbar-stub"); | 354 ClickOnControl("toolbar-stub"); |
| 354 | 355 |
| 355 EXPECT_TRUE(HtmlElementVisible("session-toolbar")); | 356 EXPECT_TRUE(HtmlElementVisible("session-toolbar")); |
| 356 | 357 |
| 357 ClickOnControl("toolbar-disconnect"); | 358 ClickOnControl("toolbar-disconnect"); |
| 358 | 359 |
| 359 EXPECT_TRUE(HtmlElementVisible("client-dialog")); | 360 EXPECT_TRUE(HtmlElementVisible("client-dialog")); |
| 360 EXPECT_TRUE(HtmlElementVisible("client-reconnect-button")); | 361 EXPECT_TRUE(HtmlElementVisible("client-reconnect-button")); |
| 361 EXPECT_TRUE(HtmlElementVisible("client-finished-me2me-button")); | 362 EXPECT_TRUE(HtmlElementVisible("client-finished-me2me-button")); |
| 362 | 363 |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 ASSERT_TRUE(dict_value->GetBoolean("succeeded", &succeeded)); | 701 ASSERT_TRUE(dict_value->GetBoolean("succeeded", &succeeded)); |
| 701 ASSERT_TRUE(dict_value->GetString("error_message", &error_message)); | 702 ASSERT_TRUE(dict_value->GetString("error_message", &error_message)); |
| 702 ASSERT_TRUE(dict_value->GetString("stack_trace", &stack_trace)); | 703 ASSERT_TRUE(dict_value->GetString("stack_trace", &stack_trace)); |
| 703 | 704 |
| 704 EXPECT_TRUE(succeeded) << error_message << "\n" << stack_trace; | 705 EXPECT_TRUE(succeeded) << error_message << "\n" << stack_trace; |
| 705 } | 706 } |
| 706 | 707 |
| 707 void RemoteDesktopBrowserTest::ClickOnControl(const std::string& name) { | 708 void RemoteDesktopBrowserTest::ClickOnControl(const std::string& name) { |
| 708 ASSERT_TRUE(HtmlElementVisible(name)); | 709 ASSERT_TRUE(HtmlElementVisible(name)); |
| 709 | 710 |
| 710 ConditionalTimeoutWaiter waiter( | 711 std::string check_for_disabled = |
|
Jamie
2014/09/19 20:29:45
Maybe call this has_disabled_attribute?
anandc
2014/09/19 22:34:26
Ah, but that takes the line beyond 80 chars. :-)
D
| |
| 711 base::TimeDelta::FromSeconds(5), | 712 "document.getElementById(\"" + name + "\").hasAttribute('disabled')"; |
|
Jamie
2014/09/19 20:29:45
Nit: Use single quotes for JS code (it also means
anandc
2014/09/19 22:34:26
Done.
| |
| 712 base::TimeDelta::FromMilliseconds(500), | 713 |
| 713 base::Bind(&RemoteDesktopBrowserTest::IsEnabled, | 714 if (ExecuteScriptAndExtractBool(active_web_contents(), check_for_disabled)) { |
| 714 active_web_contents(), name)); | 715 // This element has a disabled attribute. Wait for it become enabled. |
| 715 ASSERT_TRUE(waiter.Wait()); | 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 |