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

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc

Issue 1701563002: Refactor ProfileInfoCache in c/b/ui/views (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments Created 4 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
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.cc ('k') | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/ui/views/profiles/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/test/histogram_tester.h" 13 #include "base/test/histogram_tester.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/extensions/extension_browsertest.h" 16 #include "chrome/browser/extensions/extension_browsertest.h"
17 #include "chrome/browser/profiles/profile_attributes_entry.h"
18 #include "chrome/browser/profiles/profile_attributes_storage.h"
17 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/browser/profiles/profile_metrics.h" 20 #include "chrome/browser/profiles/profile_metrics.h"
19 #include "chrome/browser/profiles/profiles_state.h" 21 #include "chrome/browser/profiles/profiles_state.h"
20 #include "chrome/browser/ui/browser_list.h" 22 #include "chrome/browser/ui/browser_list.h"
21 #include "chrome/browser/ui/user_manager.h" 23 #include "chrome/browser/ui/user_manager.h"
22 #include "chrome/browser/ui/views/frame/browser_view.h" 24 #include "chrome/browser/ui/views/frame/browser_view.h"
23 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" 25 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
24 #include "chrome/browser/ui/views/profiles/user_manager_view.h" 26 #include "chrome/browser/ui/views/profiles/user_manager_view.h"
25 #include "chrome/common/chrome_paths.h" 27 #include "chrome/common/chrome_paths.h"
26 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 ProfileManager* profile_manager = g_browser_process->profile_manager(); 63 ProfileManager* profile_manager = g_browser_process->profile_manager();
62 Profile* profile = 64 Profile* profile =
63 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS); 65 Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS);
64 profile_manager->RegisterTestingProfile(profile, true, false); 66 profile_manager->RegisterTestingProfile(profile, true, false);
65 return profile; 67 return profile;
66 } 68 }
67 69
68 // Set up the profiles to enable Lock. Takes as parameter a profile that will be 70 // Set up the profiles to enable Lock. Takes as parameter a profile that will be
69 // signed in, and also creates a supervised user (necessary for lock). 71 // signed in, and also creates a supervised user (necessary for lock).
70 void SetupProfilesForLock(Profile* signed_in) { 72 void SetupProfilesForLock(Profile* signed_in) {
71 const char* signed_in_email = "me@google.com"; 73 const char signed_in_email[] = "me@google.com";
74
75 // Set up the |signed_in| profile.
76 ProfileAttributesStorage* storage =
77 &g_browser_process->profile_manager()->GetProfileAttributesStorage();
78 ProfileAttributesEntry* entry_signed_in;
79 ASSERT_TRUE(storage->GetProfileAttributesWithPath(signed_in->GetPath(),
80 &entry_signed_in));
81 entry_signed_in->SetAuthInfo("12345", base::UTF8ToUTF16(signed_in_email));
82 signed_in->GetPrefs()->SetString(prefs::kGoogleServicesHostedDomain,
83 "google.com");
84
85 // Create the |supervised| profile, which is supervised by |signed_in|.
86 ProfileAttributesEntry* entry_supervised;
72 Profile* supervised = CreateTestingProfile("supervised"); 87 Profile* supervised = CreateTestingProfile("supervised");
73 ProfileInfoCache* cache = &g_browser_process->profile_manager()-> 88 ASSERT_TRUE(storage->GetProfileAttributesWithPath(supervised->GetPath(),
74 GetProfileInfoCache(); 89 &entry_supervised));
75 cache->SetAuthInfoOfProfileAtIndex(cache->GetIndexOfProfileWithPath( 90 entry_supervised->SetSupervisedUserId(signed_in_email);
76 signed_in->GetPath()), "12345", base::UTF8ToUTF16(signed_in_email));
77 signed_in->GetPrefs()->
78 SetString(prefs::kGoogleServicesHostedDomain, "google.com");
79 cache->SetSupervisedUserIdOfProfileAtIndex(cache->GetIndexOfProfileWithPath(
80 supervised->GetPath()), signed_in_email);
81 91
92 // |signed_in| should now be lockable.
82 EXPECT_TRUE(profiles::IsLockAvailable(signed_in)); 93 EXPECT_TRUE(profiles::IsLockAvailable(signed_in));
83 } 94 }
84 95
85 views::View* FindWebView(views::View* view) { 96 views::View* FindWebView(views::View* view) {
86 std::queue<views::View*> queue; 97 std::queue<views::View*> queue;
87 queue.push(view); 98 queue.push(view);
88 while (!queue.empty()) { 99 while (!queue.empty()) {
89 views::View* current = queue.front(); 100 views::View* current = queue.front();
90 queue.pop(); 101 queue.pop();
91 if (current->GetClassName() == views::WebView::kViewClassName) 102 if (current->GetClassName() == views::WebView::kViewClassName)
(...skipping 16 matching lines...) Expand all
108 void SetUp() override { 119 void SetUp() override {
109 ExtensionBrowserTest::SetUp(); 120 ExtensionBrowserTest::SetUp();
110 DCHECK(switches::IsNewProfileManagement()); 121 DCHECK(switches::IsNewProfileManagement());
111 } 122 }
112 123
113 void SetUpCommandLine(base::CommandLine* command_line) override { 124 void SetUpCommandLine(base::CommandLine* command_line) override {
114 ExtensionBrowserTest::SetUpCommandLine(command_line); 125 ExtensionBrowserTest::SetUpCommandLine(command_line);
115 switches::EnableNewProfileManagementForTesting(command_line); 126 switches::EnableNewProfileManagementForTesting(command_line);
116 } 127 }
117 128
118 void OpenProfileChooserView(Browser* browser){ 129 void OpenProfileChooserView(Browser* browser) {
119 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); 130 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
120 views::View* button = browser_view->frame()->GetNewAvatarMenuButton(); 131 views::View* button = browser_view->frame()->GetNewAvatarMenuButton();
121 if (!button) 132 if (!button)
122 NOTREACHED() << "NewAvatarButton not found."; 133 NOTREACHED() << "NewAvatarButton not found.";
123 if (browser_view->frame()->GetAvatarMenuButton()) 134 if (browser_view->frame()->GetAvatarMenuButton())
124 NOTREACHED() << "Old Avatar Menu Button found."; 135 NOTREACHED() << "Old Avatar Menu Button found.";
125 136
126 ProfileChooserView::close_on_deactivate_for_testing_ = false; 137 ProfileChooserView::close_on_deactivate_for_testing_ = false;
127 138
128 ui::MouseEvent e(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), 139 ui::MouseEvent e(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(),
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 EXPECT_EQ(1U, BrowserList::GetInstance()->size()); 328 EXPECT_EQ(1U, BrowserList::GetInstance()->size());
318 329
319 WaitForUserManager(); 330 WaitForUserManager();
320 // Assert that the first profile's extensions are not blocked. 331 // Assert that the first profile's extensions are not blocked.
321 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size()); 332 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size());
322 ASSERT_EQ(0U, registry->blocked_extensions().size()); 333 ASSERT_EQ(0U, registry->blocked_extensions().size());
323 334
324 // We need to hide the User Manager or else the process can't die. 335 // We need to hide the User Manager or else the process can't die.
325 UserManager::Hide(); 336 UserManager::Hide();
326 } 337 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698