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/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 Loading... |
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( | |
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()); | |
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 // why this is needed for the v1 app to work. | 461 // why this is needed for the v1 app to work. |
477 // Without this timeout the test fail with a "CloseWebContents called for | 462 // Without this timeout the test fail with a "CloseWebContents called for |
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(); |
| 471 LoadScript(app_web_content(), FILE_PATH_LITERAL("browser_test.js")); |
486 Auth(); | 472 Auth(); |
487 ExpandMe2Me(); | 473 ExpandMe2Me(); |
488 LoadScript(app_web_content(), FILE_PATH_LITERAL("browser_test.js")); | 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 // TODO(kelvinp): This function currently only works on linux when the user is |
| 487 // already part of the chrome-remote-desktop group. Extend this functionality |
| 488 // to Mac (https://crbug.com/397576) and Windows (https://crbug.com/397575). |
| 489 bool result; |
| 490 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 491 app_web_content(), |
| 492 "browserTest.ensureRemoteConnectionEnabled(" + me2me_pin() + ")", |
| 493 &result)); |
| 494 EXPECT_TRUE(result) << "Cannot start the host with Pin:" << me2me_pin(); |
| 495 } |
| 496 |
497 void RemoteDesktopBrowserTest::ConnectToLocalHost(bool remember_pin) { | 497 void RemoteDesktopBrowserTest::ConnectToLocalHost(bool remember_pin) { |
498 // Verify that the local host is online. | 498 // Verify that the local host is online. |
499 ASSERT_TRUE(ExecuteScriptAndExtractBool( | 499 ASSERT_TRUE(ExecuteScriptAndExtractBool( |
500 "remoting.hostList.localHost_.hostName && " | 500 "remoting.hostList.localHost_.hostName && " |
501 "remoting.hostList.localHost_.hostId && " | 501 "remoting.hostList.localHost_.hostId && " |
502 "remoting.hostList.localHost_.status && " | 502 "remoting.hostList.localHost_.status && " |
503 "remoting.hostList.localHost_.status == 'ONLINE'")); | 503 "remoting.hostList.localHost_.status == 'ONLINE'")); |
504 | 504 |
505 // Connect. | 505 // Connect. |
506 ClickOnControl("this-host-connect"); | 506 ClickOnControl("this-host-connect"); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 // static | 795 // static |
796 bool RemoteDesktopBrowserTest::IsHostActionComplete( | 796 bool RemoteDesktopBrowserTest::IsHostActionComplete( |
797 content::WebContents* client_web_content, | 797 content::WebContents* client_web_content, |
798 std::string host_action_var) { | 798 std::string host_action_var) { |
799 return ExecuteScriptAndExtractBool( | 799 return ExecuteScriptAndExtractBool( |
800 client_web_content, | 800 client_web_content, |
801 host_action_var); | 801 host_action_var); |
802 } | 802 } |
803 | 803 |
804 } // namespace remoting | 804 } // namespace remoting |
OLD | NEW |