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.
5 #import "chrome/browser/ui/cocoa/history_overlay_controller.h"
7 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
9 class HistoryOverlayControllerTest : public CocoaTest {
11 void SetUp() override {
14 // The overlay controller shows the panel as a subview of the given view.
15 test_view_.reset([[NSView alloc] initWithFrame:NSMakeRect(10, 10, 10, 10)]);
17 // We add it to the test_window for authenticity.
18 [[test_window() contentView] addSubview:test_view_];
26 base::scoped_nsobject<NSView> test_view_;
29 // Tests that the overlay view gets added and removed at the appropriate times.
30 TEST_F(HistoryOverlayControllerTest, DismissClearsAnimationsAndRemovesView) {
31 EXPECT_EQ(0u, [[test_view() subviews] count]);
33 base::scoped_nsobject<HistoryOverlayController> controller(
34 [[HistoryOverlayController alloc] initForMode:kHistoryOverlayModeBack]);
35 [controller showPanelForView:test_view()];
36 EXPECT_EQ(1u, [[test_view() subviews] count]);
38 // We expect the view to be removed from its superview immediately
39 // after dismiss, even though it may still be animating a fade out.
41 EXPECT_EQ(0u, [[test_view() subviews] count]);