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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm

Issue 10823130: [Mac] Position the avatar and fullscreen buttons when adding the first profile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address comments Created 8 years, 4 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/cocoa/browser/avatar_button_controller.mm ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
6
7 #import "base/mac/mac_util.h"
8 #include "base/run_loop.h"
9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h"
16 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h"
17 #include "chrome/test/base/in_process_browser_test.h"
18
19 #if !defined(MAC_OS_X_VERSION_10_7) || \
20 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
21 enum {
22 NSWindowDocumentVersionsButton = 6,
23 NSWindowFullScreenButton
24 };
25 #endif // MAC_OS_X_VERSION_10_7
26
27 typedef InProcessBrowserTest BrowserWindowControllerTest;
28
29 void CreateProfileCallback(const base::Closure& quit_closure,
30 Profile* profile,
31 Profile::CreateStatus status) {
32 EXPECT_TRUE(profile);
33 EXPECT_NE(Profile::CREATE_STATUS_FAIL, status);
34 // This will be called multiple times. Wait until the profile is initialized
35 // fully to quit the loop.
36 if (status == Profile::CREATE_STATUS_INITIALIZED)
37 quit_closure.Run();
38 }
39
40 // Tests that adding the first profile moves the Lion fullscreen button over
41 // correctly.
42 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
43 ProfileAvatarFullscreenButton) {
44 if (base::mac::IsOSSnowLeopardOrEarlier())
45 return;
46
47 // Initialize the locals.
48 ProfileManager* profile_manager = g_browser_process->profile_manager();
49 ASSERT_TRUE(profile_manager);
50
51 NSWindow* window = browser()->window()->GetNativeWindow();
52 ASSERT_TRUE(window);
53
54 BrowserWindowController* controller =
55 static_cast<BrowserWindowCocoa*>(browser()->window())->cocoa_controller();
56
57 // With only one profile, the fullscreen button should be visible, but the
58 // avatar button should not.
59 EXPECT_EQ(1u, profile_manager->GetNumberOfProfiles());
60
61 NSButton* fullscreen_button =
62 [window standardWindowButton:NSWindowFullScreenButton];
63 EXPECT_TRUE(fullscreen_button);
64 EXPECT_FALSE([fullscreen_button isHidden]);
65
66 AvatarButtonController* avatar_controller =
67 [controller avatarButtonController];
68 NSView* avatar = [avatar_controller view];
69 EXPECT_TRUE(avatar);
70 EXPECT_TRUE([avatar isHidden]);
71
72 // Create a profile asynchronously and run the loop until its creation
73 // is complete.
74 base::RunLoop run_loop;
75
76 ProfileManager::CreateCallback create_callback =
77 base::Bind(&CreateProfileCallback, run_loop.QuitClosure());
78 profile_manager->CreateProfileAsync(
79 profile_manager->user_data_dir().Append("test"),
80 create_callback,
81 ASCIIToUTF16("avatar_test"),
82 string16());
83
84 run_loop.Run();
85
86 // There should now be two profiles, and the avatar button and fullscreen
87 // button are both visible.
88 EXPECT_EQ(2u, profile_manager->GetNumberOfProfiles());
89 EXPECT_FALSE([avatar isHidden]);
90 EXPECT_FALSE([fullscreen_button isHidden]);
91 EXPECT_EQ([avatar window], [fullscreen_button window]);
92
93 // Make sure the visual order of the buttons is correct and that they don't
94 // overlap.
95 NSRect avatar_frame = [avatar frame];
96 NSRect fullscreen_frame = [fullscreen_button frame];
97
98 EXPECT_LT(NSMinX(fullscreen_frame), NSMinX(avatar_frame));
99 EXPECT_LT(NSMaxX(fullscreen_frame), NSMinX(avatar_frame));
100 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser/avatar_button_controller.mm ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698