OLD | NEW |
---|---|
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/app_window.h" | 5 #include "apps/app_window.h" |
6 #include "apps/app_window_registry.h" | 6 #include "apps/app_window_registry.h" |
7 #include "apps/ui/native_app_window.h" | 7 #include "apps/ui/native_app_window.h" |
8 #include "ash/desktop_background/desktop_background_controller.h" | 8 #include "ash/desktop_background/desktop_background_controller.h" |
9 #include "ash/desktop_background/desktop_background_controller_observer.h" | 9 #include "ash/desktop_background/desktop_background_controller_observer.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 31 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
32 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" | 32 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" |
33 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " | 33 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " |
34 #include "chrome/browser/extensions/extension_service.h" | 34 #include "chrome/browser/extensions/extension_service.h" |
35 #include "chrome/browser/extensions/extension_test_message_listener.h" | 35 #include "chrome/browser/extensions/extension_test_message_listener.h" |
36 #include "chrome/browser/profiles/profile_impl.h" | 36 #include "chrome/browser/profiles/profile_impl.h" |
37 #include "chrome/browser/profiles/profiles_state.h" | 37 #include "chrome/browser/profiles/profiles_state.h" |
38 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h" | 38 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h" |
39 #include "chrome/common/chrome_constants.h" | 39 #include "chrome/common/chrome_constants.h" |
40 #include "chrome/common/chrome_paths.h" | 40 #include "chrome/common/chrome_paths.h" |
41 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
Nikita (slow)
2014/05/19 14:27:15
nit: not used
| |
42 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
43 #include "chromeos/chromeos_switches.h" | 43 #include "chromeos/chromeos_switches.h" |
44 #include "chromeos/dbus/cryptohome_client.h" | 44 #include "chromeos/dbus/cryptohome_client.h" |
45 #include "components/signin/core/common/signin_pref_names.h" | 45 #include "components/signin/core/common/signin_pref_names.h" |
46 #include "content/public/browser/notification_observer.h" | 46 #include "content/public/browser/notification_observer.h" |
47 #include "content/public/browser/notification_registrar.h" | 47 #include "content/public/browser/notification_registrar.h" |
48 #include "content/public/browser/notification_service.h" | 48 #include "content/public/browser/notification_service.h" |
49 #include "content/public/test/browser_test_utils.h" | 49 #include "content/public/test/browser_test_utils.h" |
50 #include "extensions/browser/extension_system.h" | 50 #include "extensions/browser/extension_system.h" |
51 #include "google_apis/gaia/gaia_constants.h" | 51 #include "google_apis/gaia/gaia_constants.h" |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 // Show kiosk enable screen again. | 863 // Show kiosk enable screen again. |
864 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", | 864 GetLoginUI()->CallJavascriptFunction("cr.ui.Oobe.handleAccelerator", |
865 base::StringValue("kiosk_enable")); | 865 base::StringValue("kiosk_enable")); |
866 | 866 |
867 // And it should show up. | 867 // And it should show up. |
868 content::WindowedNotificationObserver( | 868 content::WindowedNotificationObserver( |
869 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE, | 869 chrome::NOTIFICATION_KIOSK_ENABLE_WARNING_VISIBLE, |
870 content::NotificationService::AllSources()).Wait(); | 870 content::NotificationService::AllSources()).Wait(); |
871 } | 871 } |
872 | 872 |
873 class KioskUpdateTest : public KioskTest, | 873 class KioskUpdateTest : public KioskTest { |
874 public testing::WithParamInterface<bool> { | |
875 public: | 874 public: |
876 KioskUpdateTest() {} | 875 KioskUpdateTest() {} |
877 virtual ~KioskUpdateTest() {} | 876 virtual ~KioskUpdateTest() {} |
878 | 877 |
879 protected: | 878 protected: |
880 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 879 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
881 // Needs background networking so that ExtensionDownloader works. | 880 // Needs background networking so that ExtensionDownloader works. |
882 needs_background_networking_ = true; | 881 needs_background_networking_ = true; |
883 | |
884 KioskTest::SetUpCommandLine(command_line); | 882 KioskTest::SetUpCommandLine(command_line); |
885 if (GetParam()) | |
886 command_line->AppendSwitch(::switches::kMultiProfiles); | |
887 } | 883 } |
888 | 884 |
889 virtual void SetUpOnMainThread() OVERRIDE { | 885 virtual void SetUpOnMainThread() OVERRIDE { |
890 KioskTest::SetUpOnMainThread(); | 886 KioskTest::SetUpOnMainThread(); |
891 } | 887 } |
892 | 888 |
893 private: | 889 private: |
894 | 890 |
895 DISALLOW_COPY_AND_ASSIGN(KioskUpdateTest); | 891 DISALLOW_COPY_AND_ASSIGN(KioskUpdateTest); |
896 }; | 892 }; |
897 | 893 |
898 IN_PROC_BROWSER_TEST_P(KioskUpdateTest, LaunchOfflineEnabledAppNoNetwork) { | 894 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchOfflineEnabledAppNoNetwork) { |
899 set_test_app_id(kTestOfflineEnabledKioskApp); | 895 set_test_app_id(kTestOfflineEnabledKioskApp); |
900 | 896 |
901 PrepareAppLaunch(); | 897 PrepareAppLaunch(); |
902 SimulateNetworkOffline(); | 898 SimulateNetworkOffline(); |
903 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); | 899 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); |
904 | 900 |
905 LaunchApp(test_app_id(), false); | 901 LaunchApp(test_app_id(), false); |
906 WaitForAppLaunchSuccess(); | 902 WaitForAppLaunchSuccess(); |
907 } | 903 } |
908 | 904 |
909 IN_PROC_BROWSER_TEST_P(KioskUpdateTest, LaunchOfflineEnabledAppNoUpdate) { | 905 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchOfflineEnabledAppNoUpdate) { |
910 set_test_app_id(kTestOfflineEnabledKioskApp); | 906 set_test_app_id(kTestOfflineEnabledKioskApp); |
911 | 907 |
912 fake_cws()->SetNoUpdate(test_app_id()); | 908 fake_cws()->SetNoUpdate(test_app_id()); |
913 | 909 |
914 PrepareAppLaunch(); | 910 PrepareAppLaunch(); |
915 SimulateNetworkOnline(); | 911 SimulateNetworkOnline(); |
916 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); | 912 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); |
917 | 913 |
918 LaunchApp(test_app_id(), false); | 914 LaunchApp(test_app_id(), false); |
919 WaitForAppLaunchSuccess(); | 915 WaitForAppLaunchSuccess(); |
920 | 916 |
921 EXPECT_EQ("1.0.0", GetInstalledAppVersion().GetString()); | 917 EXPECT_EQ("1.0.0", GetInstalledAppVersion().GetString()); |
922 } | 918 } |
923 | 919 |
924 IN_PROC_BROWSER_TEST_P(KioskUpdateTest, LaunchOfflineEnabledAppHasUpdate) { | 920 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, LaunchOfflineEnabledAppHasUpdate) { |
925 set_test_app_id(kTestOfflineEnabledKioskApp); | 921 set_test_app_id(kTestOfflineEnabledKioskApp); |
926 | 922 |
927 fake_cws()->SetUpdateCrx( | 923 fake_cws()->SetUpdateCrx( |
928 test_app_id(), "ajoggoflpgplnnjkjamcmbepjdjdnpdp.crx", "2.0.0"); | 924 test_app_id(), "ajoggoflpgplnnjkjamcmbepjdjdnpdp.crx", "2.0.0"); |
929 | 925 |
930 PrepareAppLaunch(); | 926 PrepareAppLaunch(); |
931 SimulateNetworkOnline(); | 927 SimulateNetworkOnline(); |
932 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); | 928 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); |
933 | 929 |
934 LaunchApp(test_app_id(), false); | 930 LaunchApp(test_app_id(), false); |
935 WaitForAppLaunchSuccess(); | 931 WaitForAppLaunchSuccess(); |
936 | 932 |
937 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); | 933 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); |
938 } | 934 } |
939 | 935 |
940 IN_PROC_BROWSER_TEST_P(KioskUpdateTest, PermissionChange) { | 936 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PermissionChange) { |
941 set_test_app_id(kTestOfflineEnabledKioskApp); | 937 set_test_app_id(kTestOfflineEnabledKioskApp); |
942 | 938 |
943 fake_cws()->SetUpdateCrx( | 939 fake_cws()->SetUpdateCrx( |
944 test_app_id(), | 940 test_app_id(), |
945 "ajoggoflpgplnnjkjamcmbepjdjdnpdp_v2_permission_change.crx", | 941 "ajoggoflpgplnnjkjamcmbepjdjdnpdp_v2_permission_change.crx", |
946 "2.0.0"); | 942 "2.0.0"); |
947 | 943 |
948 PrepareAppLaunch(); | 944 PrepareAppLaunch(); |
949 SimulateNetworkOnline(); | 945 SimulateNetworkOnline(); |
950 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); | 946 SetupAppProfile("chromeos/app_mode/offline_enabled_app_profile"); |
951 | 947 |
952 LaunchApp(test_app_id(), false); | 948 LaunchApp(test_app_id(), false); |
953 WaitForAppLaunchSuccess(); | 949 WaitForAppLaunchSuccess(); |
954 | 950 |
955 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); | 951 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); |
956 } | 952 } |
957 | 953 |
958 IN_PROC_BROWSER_TEST_P(KioskUpdateTest, PRE_PreserveLocalData) { | 954 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PRE_PreserveLocalData) { |
959 // Installs v1 app and writes some local data. | 955 // Installs v1 app and writes some local data. |
960 set_test_app_id(kTestLocalFsKioskApp); | 956 set_test_app_id(kTestLocalFsKioskApp); |
961 | 957 |
962 ResultCatcher catcher; | 958 ResultCatcher catcher; |
963 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); | 959 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); |
964 WaitForAppLaunchSuccess(); | 960 WaitForAppLaunchSuccess(); |
965 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 961 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
966 } | 962 } |
967 | 963 |
968 IN_PROC_BROWSER_TEST_P(KioskUpdateTest, PreserveLocalData) { | 964 IN_PROC_BROWSER_TEST_F(KioskUpdateTest, PreserveLocalData) { |
969 // Update existing v1 app installed in PRE_PreserveLocalData to v2 | 965 // Update existing v1 app installed in PRE_PreserveLocalData to v2 |
970 // that reads and verifies the local data. | 966 // that reads and verifies the local data. |
971 set_test_app_id(kTestLocalFsKioskApp); | 967 set_test_app_id(kTestLocalFsKioskApp); |
972 | 968 |
973 fake_cws()->SetUpdateCrx( | 969 fake_cws()->SetUpdateCrx( |
974 test_app_id(), | 970 test_app_id(), |
975 "bmbpicmpniaclbbpdkfglgipkkebnbjf_v2_read_and_verify_data.crx", | 971 "bmbpicmpniaclbbpdkfglgipkkebnbjf_v2_read_and_verify_data.crx", |
976 "2.0.0"); | 972 "2.0.0"); |
977 | 973 |
978 ResultCatcher catcher; | 974 ResultCatcher catcher; |
979 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); | 975 StartAppLaunchFromLoginScreen(SimulateNetworkOnlineClosure()); |
980 WaitForAppLaunchSuccess(); | 976 WaitForAppLaunchSuccess(); |
981 | 977 |
982 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); | 978 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); |
983 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 979 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
984 } | 980 } |
985 | 981 |
986 // TODO(xiyuan): Remove this after multi profile is turned on by default. | |
987 INSTANTIATE_TEST_CASE_P(KioskUpdateTestInstantiation, | |
988 KioskUpdateTest, | |
989 testing::Bool()); | |
990 | |
991 class KioskEnterpriseTest : public KioskTest { | 982 class KioskEnterpriseTest : public KioskTest { |
992 protected: | 983 protected: |
993 KioskEnterpriseTest() {} | 984 KioskEnterpriseTest() {} |
994 | 985 |
995 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 986 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
996 device_policy_test_helper_.MarkAsEnterpriseOwned(); | 987 device_policy_test_helper_.MarkAsEnterpriseOwned(); |
997 device_policy_test_helper_.InstallOwnerKey(); | 988 device_policy_test_helper_.InstallOwnerKey(); |
998 | 989 |
999 KioskTest::SetUpInProcessBrowserTestFixture(); | 990 KioskTest::SetUpInProcessBrowserTestFixture(); |
1000 } | 991 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1196 content::WindowedNotificationObserver( | 1187 content::WindowedNotificationObserver( |
1197 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, | 1188 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, |
1198 content::NotificationService::AllSources()).Wait(); | 1189 content::NotificationService::AllSources()).Wait(); |
1199 | 1190 |
1200 // Wait for the wallpaper to load. | 1191 // Wait for the wallpaper to load. |
1201 WaitForWallpaper(); | 1192 WaitForWallpaper(); |
1202 EXPECT_TRUE(wallpaper_loaded()); | 1193 EXPECT_TRUE(wallpaper_loaded()); |
1203 } | 1194 } |
1204 | 1195 |
1205 } // namespace chromeos | 1196 } // namespace chromeos |
OLD | NEW |