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

Side by Side Diff: chrome/browser/chromeos/file_manager/file_manager_browsertest.cc

Issue 163183002: Files.app add multi-profile test with maximum number of profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
« no previous file with comments | « no previous file | 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 (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 // Browser test for basic Chrome OS file manager functionality: 5 // Browser test for basic Chrome OS file manager functionality:
6 // - The file list is updated when a file is added externally to the Downloads 6 // - The file list is updated when a file is added externally to the Downloads
7 // folder. 7 // folder.
8 // - Selecting a file and copy-pasting it with the keyboard copies the file. 8 // - Selecting a file and copy-pasting it with the keyboard copies the file.
9 // - Selecting a file and pressing delete deletes it. 9 // - Selecting a file and pressing delete deletes it.
10 10
11 #include <deque> 11 #include <deque>
12 #include <string> 12 #include <string>
13 13
14 #include "apps/shell_window.h" 14 #include "apps/shell_window.h"
15 #include "apps/shell_window_registry.h" 15 #include "apps/shell_window_registry.h"
16 #include "ash/session_state_delegate.h"
17 #include "ash/shell.h"
16 #include "base/bind.h" 18 #include "base/bind.h"
17 #include "base/callback.h" 19 #include "base/callback.h"
18 #include "base/file_util.h" 20 #include "base/file_util.h"
19 #include "base/files/file_path.h" 21 #include "base/files/file_path.h"
20 #include "base/json/json_reader.h" 22 #include "base/json/json_reader.h"
21 #include "base/json/json_value_converter.h" 23 #include "base/json/json_value_converter.h"
22 #include "base/json/json_writer.h" 24 #include "base/json/json_writer.h"
23 #include "base/prefs/pref_service.h" 25 #include "base/prefs/pref_service.h"
24 #include "base/strings/string_piece.h" 26 #include "base/strings/string_piece.h"
27 #include "base/strings/stringprintf.h"
25 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
26 #include "base/time/time.h" 29 #include "base/time/time.h"
27 #include "chrome/browser/browser_process.h" 30 #include "chrome/browser/browser_process.h"
28 #include "chrome/browser/chrome_notification_types.h" 31 #include "chrome/browser/chrome_notification_types.h"
29 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 32 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
30 #include "chrome/browser/chromeos/drive/file_system_interface.h" 33 #include "chrome/browser/chromeos/drive/file_system_interface.h"
31 #include "chrome/browser/chromeos/drive/test_util.h" 34 #include "chrome/browser/chromeos/drive/test_util.h"
32 #include "chrome/browser/chromeos/file_manager/app_id.h" 35 #include "chrome/browser/chromeos/file_manager/app_id.h"
33 #include "chrome/browser/chromeos/file_manager/drive_test_util.h" 36 #include "chrome/browser/chromeos/file_manager/drive_test_util.h"
34 #include "chrome/browser/chromeos/file_manager/path_util.h" 37 #include "chrome/browser/chromeos/file_manager/path_util.h"
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 } 854 }
852 855
853 // Loads all users to the current session and sets up necessary fields. 856 // Loads all users to the current session and sets up necessary fields.
854 // This is used for preparing all accounts in PRE_ test setup, and for testing 857 // This is used for preparing all accounts in PRE_ test setup, and for testing
855 // actual login behavior. 858 // actual login behavior.
856 void AddAllUsers() { 859 void AddAllUsers() {
857 for (size_t i = 0; i < arraysize(kTestAccounts); ++i) 860 for (size_t i = 0; i < arraysize(kTestAccounts); ++i)
858 AddUser(kTestAccounts[i], i >= SECONDARY_ACCOUNT_INDEX_START); 861 AddUser(kTestAccounts[i], i >= SECONDARY_ACCOUNT_INDEX_START);
859 } 862 }
860 863
864 // Add as many as users
865 void AddExtraUsersForStressTesting() {
866 ash::Shell* const shell = ash::Shell::GetInstance();
867 const size_t maxLogin =
868 shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers();
869
870 for (int i = 0; i + arraysize(kTestAccounts) < maxLogin; ++i) {
871 const std::string email = base::StringPrintf("user%d@invalid.domain", i);
872 const std::string hash = base::StringPrintf("hashuser%d", i);
873 const std::string name = base::StringPrintf("Additional User %d", i);
874 const TestAccountInfo info = {email.c_str(), hash.c_str(), name.c_str()};
875 AddUser(info, true);
876 }
877 }
878
861 // Returns primary profile (if it is already created.) 879 // Returns primary profile (if it is already created.)
862 virtual Profile* profile() OVERRIDE { 880 virtual Profile* profile() OVERRIDE {
863 Profile* const profile = chromeos::ProfileHelper::GetProfileByUserIdHash( 881 Profile* const profile = chromeos::ProfileHelper::GetProfileByUserIdHash(
864 kTestAccounts[PRIMARY_ACCOUNT_INDEX].hash); 882 kTestAccounts[PRIMARY_ACCOUNT_INDEX].hash);
865 return profile ? profile : FileManagerBrowserTestBase::profile(); 883 return profile ? profile : FileManagerBrowserTestBase::profile();
866 } 884 }
867 885
868 // Sets the test case name (used as a function name in test_cases.js to call.) 886 // Sets the test case name (used as a function name in test_cases.js to call.)
869 void set_test_case_name(const std::string& name) { test_case_name_ = name; } 887 void set_test_case_name(const std::string& name) { test_case_name_ = name; }
870 888
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 // Sanity check that normal operations work in multi-profile setting as well. 954 // Sanity check that normal operations work in multi-profile setting as well.
937 set_test_case_name("keyboardCopyDrive"); 955 set_test_case_name("keyboardCopyDrive");
938 StartTest(); 956 StartTest();
939 } 957 }
940 958
941 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, PRE_Badge) { 959 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, PRE_Badge) {
942 AddAllUsers(); 960 AddAllUsers();
943 } 961 }
944 962
945 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, Badge) { 963 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, Badge) {
964 // Test the profile badge to be correctly shown and hidden.
946 set_test_case_name("multiProfileBadge"); 965 set_test_case_name("multiProfileBadge");
947 StartTest(); 966 StartTest();
948 } 967 }
949 968
950 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, 969 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest,
951 PRE_VisitDesktopMenu) { 970 PRE_VisitDesktopMenu) {
952 AddAllUsers(); 971 AddAllUsers();
953 } 972 }
954 973
955 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, VisitDesktopMenu) { 974 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, VisitDesktopMenu) {
975 // Test for the menu item for visiting other profile's desktop.
956 set_test_case_name("multiProfileVisitDesktopMenu"); 976 set_test_case_name("multiProfileVisitDesktopMenu");
957 StartTest(); 977 StartTest();
958 } 978 }
959 979
960 // TODO(kinaba) write more tests. 980 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, PRE_MaxUser) {
981 AddAllUsers();
982 AddExtraUsersForStressTesting();
983 }
984
985 IN_PROC_BROWSER_TEST_F(MultiProfileFileManagerBrowserTest, MaxUser) {
986 // Run the same test as VisitDesktopMenu with maximum number of users logged
987 // in and checks that nothing goes wrong. Here, the primary user (alice) logs
988 // in first, then the "extra" users follow, and then lastly the other users
989 // (bob and charlie) are added in the test. Thus the existing test verifies
990 // that the feature is effectively working with lastly logged in users.
991 AddExtraUsersForStressTesting();
992
993 set_test_case_name("multiProfileVisitDesktopMenu");
994 StartTest();
995 }
961 996
962 } // namespace 997 } // namespace
963 } // namespace file_manager 998 } // namespace file_manager
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698