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

Unified Diff: trunk/src/ui/base/cocoa/controls/hover_image_menu_button_unittest.mm

Issue 17059002: Revert 206237 "Menu for the OSX app launcher, HoverImageMenuButt..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/ui/base/cocoa/controls/hover_image_menu_button_cell.mm ('k') | trunk/src/ui/ui.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/ui/base/cocoa/controls/hover_image_menu_button_unittest.mm
===================================================================
--- trunk/src/ui/base/cocoa/controls/hover_image_menu_button_unittest.mm (revision 206373)
+++ trunk/src/ui/base/cocoa/controls/hover_image_menu_button_unittest.mm (working copy)
@@ -1,168 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "ui/base/cocoa/controls/hover_image_menu_button.h"
-
-#include "base/mac/foundation_util.h"
-#import "testing/gtest_mac.h"
-#import "ui/base/cocoa/controls/hover_image_menu_button_cell.h"
-#import "ui/base/test/ui_cocoa_test_helper.h"
-
-namespace ui {
-
-namespace {
-
-// Test initialization and display of the NSPopUpButton that shows the drop-
-// down menu. Don't try to show the menu, since it will block the thread.
-class HoverImageMenuButtonTest : public CocoaTest {
- public:
- HoverImageMenuButtonTest() {}
-
- // CocoaTest override:
- virtual void SetUp() OVERRIDE;
-
- protected:
- scoped_nsobject<HoverImageMenuButton> menu_button_;
- scoped_nsobject<NSImage> normal_;
- scoped_nsobject<NSImage> pressed_;
- scoped_nsobject<NSImage> hovered_;
-
- DISALLOW_COPY_AND_ASSIGN(HoverImageMenuButtonTest);
-};
-
-void HoverImageMenuButtonTest::SetUp() {
- menu_button_.reset(
- [[HoverImageMenuButton alloc] initWithFrame:NSMakeRect(0, 0, 50, 30)
- pullsDown:YES]);
-
- normal_.reset([base::mac::ObjCCastStrict<NSImage>(
- [NSImage imageNamed:NSImageNameStatusAvailable]) retain]);
- pressed_.reset([base::mac::ObjCCastStrict<NSImage>(
- [NSImage imageNamed:NSImageNameStatusUnavailable]) retain]);
- hovered_.reset([base::mac::ObjCCastStrict<NSImage>(
- [NSImage imageNamed:NSImageNameStatusPartiallyAvailable]) retain]);
- [[menu_button_ hoverImageMenuButtonCell] setImage:normal_];
- [[menu_button_ hoverImageMenuButtonCell] setAlternateImage:pressed_];
- [[menu_button_ hoverImageMenuButtonCell] setHoverImage:hovered_];
-
- CocoaTest::SetUp();
- [[test_window() contentView] addSubview:menu_button_];
-}
-
-} // namespace
-
-TEST_VIEW(HoverImageMenuButtonTest, menu_button_);
-
-// Tests that the correct image is chosen, depending on the cell's state flags.
-TEST_F(HoverImageMenuButtonTest, CheckImagesForState) {
- EXPECT_FALSE([[menu_button_ cell] isHovered]);
- EXPECT_FALSE([[menu_button_ cell] isHighlighted]);
- EXPECT_NSEQ(normal_, [[menu_button_ cell] imageToDraw]);
- [menu_button_ display];
-
- [[menu_button_ cell] setHovered:YES];
- EXPECT_TRUE([[menu_button_ cell] isHovered]);
- EXPECT_FALSE([[menu_button_ cell] isHighlighted]);
- EXPECT_NSEQ(hovered_, [[menu_button_ cell] imageToDraw]);
- [menu_button_ display];
-
- // Highlighted takes precendece over hover.
- [[menu_button_ cell] setHighlighted:YES];
- EXPECT_TRUE([[menu_button_ cell] isHovered]);
- EXPECT_TRUE([[menu_button_ cell] isHighlighted]);
- EXPECT_NSEQ(pressed_, [[menu_button_ cell] imageToDraw]);
- [menu_button_ display];
-
- [[menu_button_ cell] setHovered:NO];
- EXPECT_FALSE([[menu_button_ cell] isHovered]);
- EXPECT_TRUE([[menu_button_ cell] isHighlighted]);
- EXPECT_NSEQ(pressed_, [[menu_button_ cell] imageToDraw]);
- [menu_button_ display];
-
- [[menu_button_ cell] setHighlighted:NO];
- EXPECT_FALSE([[menu_button_ cell] isHovered]);
- EXPECT_FALSE([[menu_button_ cell] isHighlighted]);
- EXPECT_NSEQ(normal_, [[menu_button_ cell] imageToDraw]);
- [menu_button_ display];
-}
-
-// Tests that calling the various setXImage functions calls setNeedsDisplay.
-TEST_F(HoverImageMenuButtonTest, NewImageCausesDisplay) {
- [menu_button_ display];
- EXPECT_FALSE([menu_button_ needsDisplay]);
-
- // Note that regular setImage is overridden to ensure the image goes into the
- // NSPopUpButtonCell's menuItem.
- [[menu_button_ cell] setImage:pressed_];
-
- // Highlighting the cell requires a redisplay.
- [[menu_button_ cell] setHighlighted:YES];
- EXPECT_TRUE([menu_button_ needsDisplay]);
- [menu_button_ display];
- EXPECT_FALSE([menu_button_ needsDisplay]);
-
- // setAlternateImage comes from NSButtonCell. Ensure the added setHover*
- // behaviour matches.
- [[menu_button_ cell] setAlternateImage:normal_];
- EXPECT_TRUE([menu_button_ needsDisplay]);
- [menu_button_ display];
- EXPECT_FALSE([menu_button_ needsDisplay]);
-
- // Setting the same image should not cause a redisplay.
- [[menu_button_ cell] setAlternateImage:normal_];
- EXPECT_FALSE([menu_button_ needsDisplay]);
-
- // Unhighlighting requires a redisplay.
- [[menu_button_ cell] setHighlighted:NO];
- EXPECT_TRUE([menu_button_ needsDisplay]);
- [menu_button_ display];
- EXPECT_FALSE([menu_button_ needsDisplay]);
-
- // Changing hover state requires a redisplay.
- [[menu_button_ cell] setHovered:YES];
- EXPECT_TRUE([menu_button_ needsDisplay]);
- [menu_button_ display];
- EXPECT_FALSE([menu_button_ needsDisplay]);
-
- // setHoverImage comes directly from storage in HoverImageMenuButtonCell.
- [[menu_button_ cell] setHoverImage:normal_];
- EXPECT_TRUE([menu_button_ needsDisplay]);
- [menu_button_ display];
- EXPECT_FALSE([menu_button_ needsDisplay]);
-
- // Setting the same image should not cause a redisplay.
- [[menu_button_ cell] setHoverImage:normal_];
- EXPECT_FALSE([menu_button_ needsDisplay]);
-
- // Unhover requires a redisplay.
- [[menu_button_ cell] setHovered:NO];
- EXPECT_TRUE([menu_button_ needsDisplay]);
- [menu_button_ display];
- EXPECT_FALSE([menu_button_ needsDisplay]);
-
- // Changing the image while not hovered should not require a redisplay.
- [[menu_button_ cell] setHoverImage:pressed_];
- EXPECT_FALSE([menu_button_ needsDisplay]);
-}
-
-// Test that the mouse enter and exit is properly handled, to set hover state.
-TEST_F(HoverImageMenuButtonTest, SimulateMouseEnterExit) {
- [menu_button_ display];
- EXPECT_FALSE([menu_button_ needsDisplay]);
- EXPECT_NSEQ(normal_, [[menu_button_ cell] imageToDraw]);
-
- [menu_button_ mouseEntered:nil];
- EXPECT_TRUE([menu_button_ needsDisplay]);
- EXPECT_NSEQ(hovered_, [[menu_button_ cell] imageToDraw]);
- [menu_button_ display];
- EXPECT_FALSE([menu_button_ needsDisplay]);
-
- [menu_button_ mouseExited:nil];
- EXPECT_TRUE([menu_button_ needsDisplay]);
- EXPECT_NSEQ(normal_, [[menu_button_ cell] imageToDraw]);
- [menu_button_ display];
- EXPECT_FALSE([menu_button_ needsDisplay]);
-}
-
-} // namespace ui
« no previous file with comments | « trunk/src/ui/base/cocoa/controls/hover_image_menu_button_cell.mm ('k') | trunk/src/ui/ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698