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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_controller_unittest.mm

Issue 476313003: Mac: Improve tab strip layout in case of overflow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "base/mac/scoped_nsobject.h" 7 #import "base/mac/scoped_nsobject.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" 9 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
10 #import "chrome/browser/ui/cocoa/tabs/media_indicator_view.h" 10 #import "chrome/browser/ui/cocoa/tabs/media_indicator_view.h"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 EXPECT_FALSE([controller shouldShowCloseButton]); 361 EXPECT_FALSE([controller shouldShowCloseButton]);
362 362
363 // Setting the icon when tab is at min width should not show icon (bug 18359). 363 // Setting the icon when tab is at min width should not show icon (bug 18359).
364 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 364 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
365 base::scoped_nsobject<NSImage> image( 365 base::scoped_nsobject<NSImage> image(
366 rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON).CopyNSImage()); 366 rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON).CopyNSImage());
367 [controller setIconImage:image]; 367 [controller setIconImage:image];
368 NSView* newIcon = [controller iconView]; 368 NSView* newIcon = [controller iconView];
369 EXPECT_TRUE([newIcon isHidden]); 369 EXPECT_TRUE([newIcon isHidden]);
370 370
371 // Tab is at selected minimum width. Since it's selected, the close box 371 // Tab is at active minimum width. Since it's active, the close box
372 // should be visible. 372 // should be visible.
373 [controller setSelected:YES]; 373 [controller setActive:YES];
374 frame = [[controller view] frame]; 374 frame = [[controller view] frame];
375 frame.size.width = [TabController minSelectedTabWidth]; 375 frame.size.width = [TabController minActiveTabWidth];
376 [[controller view] setFrame:frame]; 376 [[controller view] setFrame:frame];
377 EXPECT_FALSE([controller shouldShowIcon]); 377 EXPECT_FALSE([controller shouldShowIcon]);
378 EXPECT_TRUE([newIcon isHidden]); 378 EXPECT_TRUE([newIcon isHidden]);
379 EXPECT_TRUE([controller shouldShowCloseButton]); 379 EXPECT_TRUE([controller shouldShowCloseButton]);
380 380
381 // Test expanding the tab to max width and ensure the icon and close box 381 // Test expanding the tab to max width and ensure the icon and close box
382 // get put back, even when de-selected. 382 // get put back, even when de-activated.
383 frame.size.width = [TabController maxTabWidth]; 383 frame.size.width = [TabController maxTabWidth];
384 [[controller view] setFrame:frame]; 384 [[controller view] setFrame:frame];
385 EXPECT_TRUE([controller shouldShowIcon]); 385 EXPECT_TRUE([controller shouldShowIcon]);
386 EXPECT_FALSE([newIcon isHidden]); 386 EXPECT_FALSE([newIcon isHidden]);
387 EXPECT_TRUE([controller shouldShowCloseButton]); 387 EXPECT_TRUE([controller shouldShowCloseButton]);
388 [controller setSelected:NO]; 388 [controller setActive:NO];
389 EXPECT_TRUE([controller shouldShowIcon]); 389 EXPECT_TRUE([controller shouldShowIcon]);
390 EXPECT_TRUE([controller shouldShowCloseButton]); 390 EXPECT_TRUE([controller shouldShowCloseButton]);
391 391
392 cap = [controller iconCapacity]; 392 cap = [controller iconCapacity];
393 EXPECT_GT(cap, 0); 393 EXPECT_GT(cap, 0);
394 } 394 }
395 395
396 TEST_F(TabControllerTest, Menu) { 396 TEST_F(TabControllerTest, Menu) {
397 NSWindow* window = test_window(); 397 NSWindow* window = test_window();
398 base::scoped_nsobject<TabController> controller([[TabController alloc] init]); 398 base::scoped_nsobject<TabController> controller([[TabController alloc] init]);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 [[controller mediaIndicatorView] updateIndicator:mediaState]; 517 [[controller mediaIndicatorView] updateIndicator:mediaState];
518 [controller setIconImage:favicon]; 518 [controller setIconImage:favicon];
519 519
520 // Test layout for every width from maximum to minimum. 520 // Test layout for every width from maximum to minimum.
521 NSRect tabFrame = [[controller view] frame]; 521 NSRect tabFrame = [[controller view] frame];
522 int minWidth; 522 int minWidth;
523 if (isMiniTab) { 523 if (isMiniTab) {
524 tabFrame.size.width = minWidth = [TabController miniTabWidth]; 524 tabFrame.size.width = minWidth = [TabController miniTabWidth];
525 } else { 525 } else {
526 tabFrame.size.width = [TabController maxTabWidth]; 526 tabFrame.size.width = [TabController maxTabWidth];
527 minWidth = isActiveTab ? [TabController minSelectedTabWidth] : 527 minWidth = isActiveTab ? [TabController minActiveTabWidth] :
528 [TabController minTabWidth]; 528 [TabController minTabWidth];
529 } 529 }
530 while (NSWidth(tabFrame) >= minWidth) { 530 while (NSWidth(tabFrame) >= minWidth) {
531 SCOPED_TRACE(::testing::Message() << "width=" << tabFrame.size.width); 531 SCOPED_TRACE(::testing::Message() << "width=" << tabFrame.size.width);
532 [[controller view] setFrame:tabFrame]; 532 [[controller view] setFrame:tabFrame];
533 CheckForExpectedLayoutAndVisibilityOfSubviews(controller); 533 CheckForExpectedLayoutAndVisibilityOfSubviews(controller);
534 --tabFrame.size.width; 534 --tabFrame.size.width;
535 } 535 }
536 } 536 }
537 } 537 }
538 } 538 }
539 } 539 }
540 540
541 } // namespace 541 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698