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

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

Issue 544403002: Fix Auth browser-test failure: make sure element is ready to receive click. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Assert if Accept button doesn't become active. Created 6 years, 3 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/path_service.h" 10 #include "base/path_service.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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(), name));
715 ASSERT_TRUE(waiter.Wait());
716
711 ExecuteScript("document.getElementById(\"" + name + "\").click();"); 717 ExecuteScript("document.getElementById(\"" + name + "\").click();");
712 } 718 }
713 719
714 void RemoteDesktopBrowserTest::EnterPin(const std::string& pin, 720 void RemoteDesktopBrowserTest::EnterPin(const std::string& pin,
715 bool remember_pin) { 721 bool remember_pin) {
716 // Wait for the pin-form to be displayed. This can take a while. 722 // 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. 723 // 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 724 // TODO(weitaosu) 1: Instead of polling, can we register a callback to be
719 // called when the pin-form is ready? 725 // called when the pin-form is ready?
720 // TODO(weitaosu) 2: Instead of blindly dismiss the host-needs-update dialog, 726 // TODO(weitaosu) 2: Instead of blindly dismiss the host-needs-update dialog,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 800
795 // static 801 // static
796 bool RemoteDesktopBrowserTest::IsHostActionComplete( 802 bool RemoteDesktopBrowserTest::IsHostActionComplete(
797 content::WebContents* client_web_content, 803 content::WebContents* client_web_content,
798 std::string host_action_var) { 804 std::string host_action_var) {
799 return ExecuteScriptAndExtractBool( 805 return ExecuteScriptAndExtractBool(
800 client_web_content, 806 client_web_content,
801 host_action_var); 807 host_action_var);
802 } 808 }
803 809
810 // static
811 bool RemoteDesktopBrowserTest::IsEnabled(
812 content::WebContents* client_web_content,
813 const std::string& element_name) {
814 return !ExecuteScriptAndExtractBool(
815 client_web_content,
816 "document.getElementById(\"" + element_name + "\").disabled");
817 }
818
804 } // namespace remoting 819 } // 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