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

Side by Side Diff: chrome/browser/chromeos/login/kiosk_browsertest.cc

Issue 571973006: kiosk: Add a zoom test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « no previous file | chrome/test/data/chromeos/app_mode/kiosk_test_app/src/app_main.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "apps/ui/views/native_app_window_views.h"
5 #include "ash/desktop_background/desktop_background_controller.h" 6 #include "ash/desktop_background/desktop_background_controller.h"
6 #include "ash/desktop_background/desktop_background_controller_observer.h" 7 #include "ash/desktop_background/desktop_background_controller_observer.h"
7 #include "ash/shell.h" 8 #include "ash/shell.h"
8 #include "base/bind.h" 9 #include "base/bind.h"
9 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
10 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
11 #include "base/location.h" 12 #include "base/location.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/path_service.h" 14 #include "base/path_service.h"
14 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "content/public/test/browser_test_utils.h" 56 #include "content/public/test/browser_test_utils.h"
56 #include "extensions/browser/app_window/app_window.h" 57 #include "extensions/browser/app_window/app_window.h"
57 #include "extensions/browser/app_window/app_window_registry.h" 58 #include "extensions/browser/app_window/app_window_registry.h"
58 #include "extensions/browser/app_window/native_app_window.h" 59 #include "extensions/browser/app_window/native_app_window.h"
59 #include "extensions/browser/extension_system.h" 60 #include "extensions/browser/extension_system.h"
60 #include "extensions/test/result_catcher.h" 61 #include "extensions/test/result_catcher.h"
61 #include "google_apis/gaia/gaia_constants.h" 62 #include "google_apis/gaia/gaia_constants.h"
62 #include "google_apis/gaia/gaia_switches.h" 63 #include "google_apis/gaia/gaia_switches.h"
63 #include "google_apis/gaia/gaia_urls.h" 64 #include "google_apis/gaia/gaia_urls.h"
64 #include "net/test/embedded_test_server/embedded_test_server.h" 65 #include "net/test/embedded_test_server/embedded_test_server.h"
66 #include "ui/base/accelerators/accelerator.h"
65 67
66 namespace em = enterprise_management; 68 namespace em = enterprise_management;
67 69
68 namespace chromeos { 70 namespace chromeos {
69 71
70 namespace { 72 namespace {
71 73
72 // This is a simple test app that creates an app window and immediately closes 74 // This is a simple test app that creates an app window and immediately closes
73 // it again. Webstore data json is in 75 // it again. Webstore data json is in
74 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/ 76 // chrome/test/data/chromeos/app_mode/webstore/inlineinstall/
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 const extensions::Extension* GetInstalledApp() { 416 const extensions::Extension* GetInstalledApp() {
415 Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); 417 Profile* app_profile = ProfileManager::GetPrimaryUserProfile();
416 return extensions::ExtensionSystem::Get(app_profile)-> 418 return extensions::ExtensionSystem::Get(app_profile)->
417 extension_service()->GetInstalledExtension(test_app_id_); 419 extension_service()->GetInstalledExtension(test_app_id_);
418 } 420 }
419 421
420 const Version& GetInstalledAppVersion() { 422 const Version& GetInstalledAppVersion() {
421 return *GetInstalledApp()->version(); 423 return *GetInstalledApp()->version();
422 } 424 }
423 425
424 void WaitForAppLaunchSuccess() { 426 void WaitForAppLaunchAndOptionallyTerminateApp(bool terminate_app) {
425 ExtensionTestMessageListener 427 ExtensionTestMessageListener
426 launch_data_check_listener("launchData.isKioskSession = true", false); 428 launch_data_check_listener("launchData.isKioskSession = true", false);
427 429
428 // Wait for the Kiosk App to launch. 430 // Wait for the Kiosk App to launch.
429 content::WindowedNotificationObserver( 431 content::WindowedNotificationObserver(
430 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED, 432 chrome::NOTIFICATION_KIOSK_APP_LAUNCHED,
431 content::NotificationService::AllSources()).Wait(); 433 content::NotificationService::AllSources()).Wait();
432 434
433 // Default profile switches to app profile after app is launched. 435 // Default profile switches to app profile after app is launched.
434 Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); 436 Profile* app_profile = ProfileManager::GetPrimaryUserProfile();
(...skipping 21 matching lines...) Expand all
456 EXPECT_TRUE(window); 458 EXPECT_TRUE(window);
457 459
458 // Login screen should be gone or fading out. 460 // Login screen should be gone or fading out.
459 chromeos::LoginDisplayHost* login_display_host = 461 chromeos::LoginDisplayHost* login_display_host =
460 chromeos::LoginDisplayHostImpl::default_host(); 462 chromeos::LoginDisplayHostImpl::default_host();
461 EXPECT_TRUE( 463 EXPECT_TRUE(
462 login_display_host == NULL || 464 login_display_host == NULL ||
463 login_display_host->GetNativeWindow()->layer()->GetTargetOpacity() == 465 login_display_host->GetNativeWindow()->layer()->GetTargetOpacity() ==
464 0.0f); 466 0.0f);
465 467
468 // Terminate the app.
469 if (terminate_app)
470 window->GetBaseWindow()->Close();
471
466 // Wait until the app terminates if it is still running. 472 // Wait until the app terminates if it is still running.
467 if (!app_window_registry->GetAppWindowsForApp(test_app_id_).empty()) 473 if (!app_window_registry->GetAppWindowsForApp(test_app_id_).empty())
468 content::RunMessageLoop(); 474 content::RunMessageLoop();
469 475
470 // Check that the app had been informed that it is running in a kiosk 476 // Check that the app had been informed that it is running in a kiosk
471 // session. 477 // session.
472 EXPECT_TRUE(launch_data_check_listener.was_satisfied()); 478 EXPECT_TRUE(launch_data_check_listener.was_satisfied());
473 } 479 }
474 480
481 void WaitForAppLaunchSuccess() {
482 WaitForAppLaunchAndOptionallyTerminateApp(true);
483 }
484
475 void WaitForAppLaunchNetworkTimeout() { 485 void WaitForAppLaunchNetworkTimeout() {
476 if (GetAppLaunchController()->network_wait_timedout()) 486 if (GetAppLaunchController()->network_wait_timedout())
477 return; 487 return;
478 488
479 scoped_refptr<content::MessageLoopRunner> runner = 489 scoped_refptr<content::MessageLoopRunner> runner =
480 new content::MessageLoopRunner; 490 new content::MessageLoopRunner;
481 491
482 base::Closure callback = base::Bind( 492 base::Closure callback = base::Bind(
483 &OnNetworkWaitTimedOut, runner->QuitClosure()); 493 &OnNetworkWaitTimedOut, runner->QuitClosure());
484 AppLaunchController::SetNetworkTimeoutCallbackForTesting(&callback); 494 AppLaunchController::SetNetworkTimeoutCallbackForTesting(&callback);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 scoped_ptr<MockUserManager> mock_user_manager_; 613 scoped_ptr<MockUserManager> mock_user_manager_;
604 614
605 DISALLOW_COPY_AND_ASSIGN(KioskTest); 615 DISALLOW_COPY_AND_ASSIGN(KioskTest);
606 }; 616 };
607 617
608 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) { 618 IN_PROC_BROWSER_TEST_F(KioskTest, InstallAndLaunchApp) {
609 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); 619 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure());
610 WaitForAppLaunchSuccess(); 620 WaitForAppLaunchSuccess();
611 } 621 }
612 622
623 IN_PROC_BROWSER_TEST_F(KioskTest, ZoomSupport) {
624 ExtensionTestMessageListener
625 app_window_loaded_listener("appWindowLoaded", false);
626 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure());
627 app_window_loaded_listener.WaitUntilSatisfied();
628
629 Profile* app_profile = ProfileManager::GetPrimaryUserProfile();
630 ASSERT_TRUE(app_profile);
631
632 extensions::AppWindowRegistry* app_window_registry =
633 extensions::AppWindowRegistry::Get(app_profile);
634 extensions::AppWindow* window =
635 AppWindowWaiter(app_window_registry, test_app_id()).Wait();
636 ASSERT_TRUE(window);
637
638 // Gets the original width of the app window.
639 int original_width;
640 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
641 window->web_contents(),
642 "window.domAutomationController.setAutomationId(0);"
643 "window.domAutomationController.send(window.innerWidth);",
644 &original_width));
645
646 apps::NativeAppWindowViews* native_app_window_views =
647 static_cast<apps::NativeAppWindowViews*>(window->GetBaseWindow());
648 ui::AcceleratorTarget* accelerator_target =
649 static_cast<ui::AcceleratorTarget*>(native_app_window_views);
650
651 // Zoom in. Text is bigger and content window width becomes smaller.
652 accelerator_target->AcceleratorPressed(ui::Accelerator(
653 ui::VKEY_ADD, ui::EF_CONTROL_DOWN));
654 int width_zoomed_in;
655 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
656 window->web_contents(),
657 "window.domAutomationController.setAutomationId(0);"
658 "window.domAutomationController.send(window.innerWidth);",
659 &width_zoomed_in));
660 DCHECK_LT(width_zoomed_in, original_width);
661
662 // Go back to normal. Window width is restored.
663 accelerator_target->AcceleratorPressed(ui::Accelerator(
664 ui::VKEY_0, ui::EF_CONTROL_DOWN));
665 int width_zoom_normal;
666 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
667 window->web_contents(),
668 "window.domAutomationController.setAutomationId(0);"
669 "window.domAutomationController.send(window.innerWidth);",
670 &width_zoom_normal));
671 DCHECK_EQ(width_zoom_normal, original_width);
672
673 // Zoom out. Text is smaller and content window width becomes larger.
674 accelerator_target->AcceleratorPressed(ui::Accelerator(
675 ui::VKEY_SUBTRACT, ui::EF_CONTROL_DOWN));
676 int width_zoomed_out;
677 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
678 window->web_contents(),
679 "window.domAutomationController.setAutomationId(0);"
680 "window.domAutomationController.send(window.innerWidth);",
681 &width_zoomed_out));
682 DCHECK_GT(width_zoomed_out, original_width);
683
684 // Terminate the app.
685 window->GetBaseWindow()->Close();
686 content::RunAllPendingInMessageLoop();
687 }
688
613 IN_PROC_BROWSER_TEST_F(KioskTest, NotSignedInWithGAIAAccount) { 689 IN_PROC_BROWSER_TEST_F(KioskTest, NotSignedInWithGAIAAccount) {
614 // Tests that the kiosk session is not considered to be logged in with a GAIA 690 // Tests that the kiosk session is not considered to be logged in with a GAIA
615 // account. 691 // account.
616 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); 692 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure());
617 WaitForAppLaunchSuccess(); 693 WaitForAppLaunchSuccess();
618 694
619 Profile* app_profile = ProfileManager::GetPrimaryUserProfile(); 695 Profile* app_profile = ProfileManager::GetPrimaryUserProfile();
620 ASSERT_TRUE(app_profile); 696 ASSERT_TRUE(app_profile);
621 EXPECT_FALSE(app_profile->GetPrefs()->HasPrefPath( 697 EXPECT_FALSE(app_profile->GetPrefs()->HasPrefPath(
622 prefs::kGoogleServicesUsername)); 698 prefs::kGoogleServicesUsername));
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 } 1528 }
1453 1529
1454 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_PreserveLocalData) { 1530 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_PreserveLocalData) {
1455 // Installs v1 app and writes some local data. 1531 // Installs v1 app and writes some local data.
1456 set_test_app_id(kTestLocalFsKioskApp); 1532 set_test_app_id(kTestLocalFsKioskApp);
1457 set_test_app_version("1.0.0"); 1533 set_test_app_version("1.0.0");
1458 set_test_crx_file(test_app_id() + ".crx"); 1534 set_test_crx_file(test_app_id() + ".crx");
1459 1535
1460 extensions::ResultCatcher catcher; 1536 extensions::ResultCatcher catcher;
1461 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); 1537 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure());
1462 WaitForAppLaunchSuccess(); 1538 WaitForAppLaunchAndOptionallyTerminateApp(false);
1463 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 1539 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
1464 } 1540 }
1465 1541
1466 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PreserveLocalData) { 1542 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PreserveLocalData) {
1467 // Update existing v1 app installed in PRE_PreserveLocalData to v2 1543 // Update existing v1 app installed in PRE_PreserveLocalData to v2
1468 // that reads and verifies the local data. 1544 // that reads and verifies the local data.
1469 set_test_app_id(kTestLocalFsKioskApp); 1545 set_test_app_id(kTestLocalFsKioskApp);
1470 set_test_app_version("2.0.0"); 1546 set_test_app_version("2.0.0");
1471 set_test_crx_file(test_app_id() + "_v2_read_and_verify_data.crx"); 1547 set_test_crx_file(test_app_id() + "_v2_read_and_verify_data.crx");
1472 extensions::ResultCatcher catcher; 1548 extensions::ResultCatcher catcher;
1473 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); 1549 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure());
1474 WaitForAppLaunchSuccess(); 1550 WaitForAppLaunchAndOptionallyTerminateApp(false);
1475 1551
1476 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); 1552 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString());
1477 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 1553 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
1478 } 1554 }
1479 1555
1480 class KioskEnterpriseTest : public KioskTest { 1556 class KioskEnterpriseTest : public KioskTest {
1481 protected: 1557 protected:
1482 KioskEnterpriseTest() {} 1558 KioskEnterpriseTest() {}
1483 1559
1484 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 1560 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 content::WindowedNotificationObserver( 1772 content::WindowedNotificationObserver(
1697 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, 1773 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE,
1698 content::NotificationService::AllSources()).Wait(); 1774 content::NotificationService::AllSources()).Wait();
1699 1775
1700 // Wait for the wallpaper to load. 1776 // Wait for the wallpaper to load.
1701 WaitForWallpaper(); 1777 WaitForWallpaper();
1702 EXPECT_TRUE(wallpaper_loaded()); 1778 EXPECT_TRUE(wallpaper_loaded());
1703 } 1779 }
1704 1780
1705 } // namespace chromeos 1781 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/chromeos/app_mode/kiosk_test_app/src/app_main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698