Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / history_overlay_controller_unittest.mm
blob91db9b011a49ad6e4facc855cb27ac5a44788026
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 {
10  public:
11   void SetUp() override {
12     CocoaTest::SetUp();
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_];
19   }
21   NSView* test_view() {
22     return test_view_;
23   }
25  private:
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.
40   [controller dismiss];
41   EXPECT_EQ(0u, [[test_view() subviews] count]);