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

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

Issue 398823005: Automate host start up in browser test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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/file_util.h" 8 #include "base/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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 // The Me2Me host list should be hidden. 336 // The Me2Me host list should be hidden.
337 ASSERT_FALSE(HtmlElementVisible("me2me-content")); 337 ASSERT_FALSE(HtmlElementVisible("me2me-content"));
338 // The Me2Me "Get Start" button should be visible. 338 // The Me2Me "Get Start" button should be visible.
339 ASSERT_TRUE(HtmlElementVisible("get-started-me2me")); 339 ASSERT_TRUE(HtmlElementVisible("get-started-me2me"));
340 340
341 // Starting Me2Me. 341 // Starting Me2Me.
342 ExecuteScript("remoting.showMe2MeUiAndSave();"); 342 ExecuteScript("remoting.showMe2MeUiAndSave();");
343 343
344 EXPECT_TRUE(HtmlElementVisible("me2me-content")); 344 EXPECT_TRUE(HtmlElementVisible("me2me-content"));
345 EXPECT_FALSE(HtmlElementVisible("me2me-first-run")); 345 EXPECT_FALSE(HtmlElementVisible("me2me-first-run"));
346
347 // Wait until localHost is initialized. This can take a while.
348 ConditionalTimeoutWaiter waiter(
kelvinp 2014/07/19 01:18:58 After the CL, we no longer assumes that the host i
Jamie 2014/07/22 18:47:11 Acknowledged.
349 base::TimeDelta::FromSeconds(3),
350 base::TimeDelta::FromSeconds(1),
351 base::Bind(&RemoteDesktopBrowserTest::IsLocalHostReady, this));
352 EXPECT_TRUE(waiter.Wait());
353
354 EXPECT_TRUE(ExecuteScriptAndExtractBool(
355 "remoting.hostList.localHost_.hostName && "
356 "remoting.hostList.localHost_.hostId && "
357 "remoting.hostList.localHost_.status && "
358 "remoting.hostList.localHost_.status == 'ONLINE'"));
359 } 346 }
360 347
361 void RemoteDesktopBrowserTest::DisconnectMe2Me() { 348 void RemoteDesktopBrowserTest::DisconnectMe2Me() {
362 // The chromoting extension should be installed. 349 // The chromoting extension should be installed.
363 ASSERT_TRUE(extension_); 350 ASSERT_TRUE(extension_);
364 351
365 // The active tab should have the chromoting app loaded.
366 ASSERT_EQ(Chromoting_Main_URL(), GetCurrentURL());
kelvinp 2014/07/19 01:18:58 This assert fails as after a PIN setup. The URL i
Jamie 2014/07/22 18:47:11 Acknowledged.
367 ASSERT_TRUE(RemoteDesktopBrowserTest::IsSessionConnected()); 352 ASSERT_TRUE(RemoteDesktopBrowserTest::IsSessionConnected());
368 353
369 ClickOnControl("toolbar-stub"); 354 ClickOnControl("toolbar-stub");
370 355
371 EXPECT_TRUE(HtmlElementVisible("session-toolbar")); 356 EXPECT_TRUE(HtmlElementVisible("session-toolbar"));
372 357
373 ClickOnControl("toolbar-disconnect"); 358 ClickOnControl("toolbar-disconnect");
374 359
375 EXPECT_TRUE(HtmlElementVisible("client-dialog")); 360 EXPECT_TRUE(HtmlElementVisible("client-dialog"));
376 EXPECT_TRUE(HtmlElementVisible("client-reconnect-button")); 361 EXPECT_TRUE(HtmlElementVisible("client-reconnect-button"));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 // tab not in our strip" error for the v1 app. 463 // tab not in our strip" error for the v1 app.
479 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait()); 464 ASSERT_TRUE(TimeoutWaiter(base::TimeDelta::FromSeconds(2)).Wait());
480 } 465 }
481 466
482 void RemoteDesktopBrowserTest::SetUpTestForMe2Me() { 467 void RemoteDesktopBrowserTest::SetUpTestForMe2Me() {
483 VerifyInternetAccess(); 468 VerifyInternetAccess();
484 Install(); 469 Install();
485 LaunchChromotingApp(); 470 LaunchChromotingApp();
486 Auth(); 471 Auth();
487 ExpandMe2Me(); 472 ExpandMe2Me();
488 LoadScript(app_web_content(), FILE_PATH_LITERAL("browser_test.js")); 473 LoadScript(app_web_content(), FILE_PATH_LITERAL("browser_test.js"));
weitao 2014/07/21 18:53:45 Ideally, loading the test script is a setup step a
kelvinp 2014/07/23 22:22:26 Done.
474 EnsureRemoteConnectionEnabled();
489 } 475 }
490 476
491 void RemoteDesktopBrowserTest::Auth() { 477 void RemoteDesktopBrowserTest::Auth() {
492 Authorize(); 478 Authorize();
493 Authenticate(); 479 Authenticate();
494 Approve(); 480 Approve();
495 } 481 }
496 482
483 void RemoteDesktopBrowserTest::EnsureRemoteConnectionEnabled() {
484 // browser_test.ensureRemoteConnectionEnabled is defined in
485 // browser_test.js, which must be loaded before calling this function.
486 bool result;
487 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
488 app_web_content(),
489 "browserTest.ensureRemoteConnectionEnabled(" + me2me_pin() + ")",
490 &result));
491 EXPECT_TRUE(result) << "Cannot start the host with Pin:" << me2me_pin();
Jamie 2014/07/22 18:47:11 Unless the PIN is likely to be a reason for failur
kelvinp 2014/07/23 22:22:26 The EXPECT_TRUE will ONLY log when the setup fails
492 }
493
497 void RemoteDesktopBrowserTest::ConnectToLocalHost(bool remember_pin) { 494 void RemoteDesktopBrowserTest::ConnectToLocalHost(bool remember_pin) {
498 // Verify that the local host is online. 495 // Verify that the local host is online.
499 ASSERT_TRUE(ExecuteScriptAndExtractBool( 496 ASSERT_TRUE(ExecuteScriptAndExtractBool(
500 "remoting.hostList.localHost_.hostName && " 497 "remoting.hostList.localHost_.hostName && "
501 "remoting.hostList.localHost_.hostId && " 498 "remoting.hostList.localHost_.hostId && "
502 "remoting.hostList.localHost_.status && " 499 "remoting.hostList.localHost_.status && "
503 "remoting.hostList.localHost_.status == 'ONLINE'")); 500 "remoting.hostList.localHost_.status == 'ONLINE'"));
504 501
505 // Connect. 502 // Connect.
506 ClickOnControl("this-host-connect"); 503 ClickOnControl("this-host-connect");
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 // static 792 // static
796 bool RemoteDesktopBrowserTest::IsHostActionComplete( 793 bool RemoteDesktopBrowserTest::IsHostActionComplete(
797 content::WebContents* client_web_content, 794 content::WebContents* client_web_content,
798 std::string host_action_var) { 795 std::string host_action_var) {
799 return ExecuteScriptAndExtractBool( 796 return ExecuteScriptAndExtractBool(
800 client_web_content, 797 client_web_content,
801 host_action_var); 798 host_action_var);
802 } 799 }
803 800
804 } // namespace remoting 801 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698