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

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: 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
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 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h"
16 #include "chrome/test/base/in_process_browser_test.h"
17
18 #if !defined(MAC_OS_X_VERSION_10_7) || \
19 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
20 enum {
21 NSWindowDocumentVersionsButton = 6,
22 NSWindowFullScreenButton
23 };
24 #endif // MAC_OS_X_VERSION_10_7
25
26 typedef InProcessBrowserTest BrowserWindowControllerTest;
27
28 void CreateProfileCallback(const base::Closure& quit_closure,
29 Profile* profile,
30 Profile::CreateStatus status) {
31 EXPECT_TRUE(profile);
32 EXPECT_NE(Profile::CREATE_STATUS_FAIL, status);
33 // This will be called multiple times. Wait until the profile is initialized
34 // fully to quit the loop.
35 if (status == Profile::CREATE_STATUS_INITIALIZED)
36 quit_closure.Run();
37 }
38
39 // Tests that adding the first profile moves the Lion fullscreen button over
40 // correctly.
41 IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest,
42 ProfileAvatarFullscreenButton) {
43 if (base::mac::IsOSSnowLeopardOrEarlier())
44 return;
45
46 // Initialize the locals.
47 ProfileManager* profile_manager = g_browser_process->profile_manager();
48 ASSERT_TRUE(profile_manager);
49
50 NSWindow* window = browser()->window()->GetNativeWindow();
51 ASSERT_TRUE(window);
52
53 BrowserWindowController* controller =
54 static_cast<BrowserWindowController*>([window windowController]);
sail 2012/08/02 00:12:40 you can also use browser()->window()->cocoa_contro
Robert Sesek 2012/08/02 00:23:40 Cool!
55 ASSERT_TRUE([controller isKindOfClass:[BrowserWindowController class]]);
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));
sail 2012/08/02 00:12:40 I don't think you need this line
Robert Sesek 2012/08/02 00:23:40 I wanted to have the fullscreen_frame MinX if it f
99 EXPECT_LT(NSMaxX(fullscreen_frame), NSMinX(avatar_frame));
100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698