| OLD | NEW |
| 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/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/test/histogram_tester.h" | 14 #include "base/test/histogram_tester.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/extensions/extension_browsertest.h" | 17 #include "chrome/browser/extensions/extension_browsertest.h" |
| 18 #include "chrome/browser/profiles/profile_attributes_entry.h" | 18 #include "chrome/browser/profiles/profile_attributes_entry.h" |
| 19 #include "chrome/browser/profiles/profile_attributes_storage.h" | 19 #include "chrome/browser/profiles/profile_attributes_storage.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/browser/profiles/profile_metrics.h" | 21 #include "chrome/browser/profiles/profile_metrics.h" |
| 22 #include "chrome/browser/profiles/profiles_state.h" | 22 #include "chrome/browser/profiles/profiles_state.h" |
| 23 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
| 24 #include "chrome/browser/ui/user_manager.h" | 24 #include "chrome/browser/ui/user_manager.h" |
| 25 #include "chrome/browser/ui/views/frame/browser_view.h" | 25 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 26 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 26 #include "chrome/browser/ui/views/profiles/profile_indicator_icon.h" |
| 27 #include "chrome/browser/ui/views/profiles/user_manager_view.h" | 27 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
| 28 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 29 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 31 #include "components/prefs/pref_service.h" | 31 #include "components/prefs/pref_service.h" |
| 32 #include "components/signin/core/common/profile_management_switches.h" | 32 #include "components/signin/core/common/profile_management_switches.h" |
| 33 #include "components/signin/core/common/signin_pref_names.h" | 33 #include "components/signin/core/common/signin_pref_names.h" |
| 34 #include "content/public/test/test_utils.h" | 34 #include "content/public/test/test_utils.h" |
| 35 #include "extensions/browser/extension_registry.h" | 35 #include "extensions/browser/extension_registry.h" |
| 36 #include "ui/events/event_utils.h" | 36 #include "ui/events/event_utils.h" |
| 37 #include "ui/views/controls/button/label_button.h" |
| 37 #include "ui/views/controls/webview/webview.h" | 38 #include "ui/views/controls/webview/webview.h" |
| 38 | 39 |
| 39 namespace { | 40 namespace { |
| 40 | 41 |
| 41 Profile* CreateTestingProfile(const std::string& profile_name) { | 42 Profile* CreateTestingProfile(const std::string& profile_name) { |
| 42 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 43 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 43 size_t starting_number_of_profiles = profile_manager->GetNumberOfProfiles(); | 44 size_t starting_number_of_profiles = profile_manager->GetNumberOfProfiles(); |
| 44 | 45 |
| 45 base::FilePath path; | 46 base::FilePath path; |
| 46 PathService::Get(chrome::DIR_USER_DATA, &path); | 47 PathService::Get(chrome::DIR_USER_DATA, &path); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 void SetUpCommandLine(base::CommandLine* command_line) override { | 126 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 126 ExtensionBrowserTest::SetUpCommandLine(command_line); | 127 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 127 switches::EnableNewProfileManagementForTesting(command_line); | 128 switches::EnableNewProfileManagementForTesting(command_line); |
| 128 } | 129 } |
| 129 | 130 |
| 130 void OpenProfileChooserView(Browser* browser) { | 131 void OpenProfileChooserView(Browser* browser) { |
| 131 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 132 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
| 132 views::View* button = browser_view->frame()->GetNewAvatarMenuButton(); | 133 views::View* button = browser_view->frame()->GetNewAvatarMenuButton(); |
| 133 if (!button) | 134 if (!button) |
| 134 NOTREACHED() << "NewAvatarButton not found."; | 135 NOTREACHED() << "NewAvatarButton not found."; |
| 135 if (browser_view->frame()->GetAvatarMenuButton()) | |
| 136 NOTREACHED() << "Old Avatar Menu Button found."; | |
| 137 | 136 |
| 138 ProfileChooserView::close_on_deactivate_for_testing_ = false; | 137 ProfileChooserView::close_on_deactivate_for_testing_ = false; |
| 139 | 138 |
| 140 ui::MouseEvent e(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), | 139 ui::MouseEvent e(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), |
| 141 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); | 140 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0); |
| 142 button->OnMouseReleased(e); | 141 button->OnMouseReleased(e); |
| 143 base::MessageLoop::current()->RunUntilIdle(); | 142 base::MessageLoop::current()->RunUntilIdle(); |
| 144 EXPECT_TRUE(ProfileChooserView::IsShowing()); | 143 EXPECT_TRUE(ProfileChooserView::IsShowing()); |
| 145 | 144 |
| 146 // Create this observer before lock is pressed to avoid a race condition. | 145 // Create this observer before lock is pressed to avoid a race condition. |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // Wait until the user manager is shown. | 338 // Wait until the user manager is shown. |
| 340 runner->Run(); | 339 runner->Run(); |
| 341 | 340 |
| 342 // Assert that the first profile's extensions are not blocked. | 341 // Assert that the first profile's extensions are not blocked. |
| 343 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size()); | 342 ASSERT_EQ(total_enabled_extensions, registry->enabled_extensions().size()); |
| 344 ASSERT_EQ(0U, registry->blocked_extensions().size()); | 343 ASSERT_EQ(0U, registry->blocked_extensions().size()); |
| 345 | 344 |
| 346 // We need to hide the User Manager or else the process can't die. | 345 // We need to hide the User Manager or else the process can't die. |
| 347 UserManager::Hide(); | 346 UserManager::Hide(); |
| 348 } | 347 } |
| OLD | NEW |