| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/ui/cocoa/base_bubble_controller.h" | 5 #import "chrome/browser/ui/cocoa/base_bubble_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
| 9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 10 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 10 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 isMenuOpen_ = NO; | 81 isMenuOpen_ = NO; |
| 82 didOpen_ = YES; | 82 didOpen_ = YES; |
| 83 } | 83 } |
| 84 | 84 |
| 85 @end | 85 @end |
| 86 | 86 |
| 87 class BaseBubbleControllerTest : public CocoaTest { | 87 class BaseBubbleControllerTest : public CocoaTest { |
| 88 public: | 88 public: |
| 89 BaseBubbleControllerTest() : controller_(nil) {} | 89 BaseBubbleControllerTest() : controller_(nil) {} |
| 90 | 90 |
| 91 virtual void SetUp() OVERRIDE { | 91 virtual void SetUp() override { |
| 92 bubble_window_.reset([[InfoBubbleWindow alloc] | 92 bubble_window_.reset([[InfoBubbleWindow alloc] |
| 93 initWithContentRect:NSMakeRect(0, 0, kBubbleWindowWidth, | 93 initWithContentRect:NSMakeRect(0, 0, kBubbleWindowWidth, |
| 94 kBubbleWindowHeight) | 94 kBubbleWindowHeight) |
| 95 styleMask:NSBorderlessWindowMask | 95 styleMask:NSBorderlessWindowMask |
| 96 backing:NSBackingStoreBuffered | 96 backing:NSBackingStoreBuffered |
| 97 defer:YES]); | 97 defer:YES]); |
| 98 [bubble_window_ setAllowedAnimations:0]; | 98 [bubble_window_ setAllowedAnimations:0]; |
| 99 | 99 |
| 100 // The bubble controller will release itself when the window closes. | 100 // The bubble controller will release itself when the window closes. |
| 101 controller_ = [[BaseBubbleController alloc] | 101 controller_ = [[BaseBubbleController alloc] |
| 102 initWithWindow:bubble_window_ | 102 initWithWindow:bubble_window_ |
| 103 parentWindow:test_window() | 103 parentWindow:test_window() |
| 104 anchoredAt:NSMakePoint(kAnchorPointX, kAnchorPointY)]; | 104 anchoredAt:NSMakePoint(kAnchorPointX, kAnchorPointY)]; |
| 105 EXPECT_TRUE([controller_ bubble]); | 105 EXPECT_TRUE([controller_ bubble]); |
| 106 EXPECT_EQ(bubble_window_.get(), [controller_ window]); | 106 EXPECT_EQ(bubble_window_.get(), [controller_ window]); |
| 107 } | 107 } |
| 108 | 108 |
| 109 virtual void TearDown() OVERRIDE { | 109 virtual void TearDown() override { |
| 110 // Close our windows. | 110 // Close our windows. |
| 111 [controller_ close]; | 111 [controller_ close]; |
| 112 bubble_window_.reset(); | 112 bubble_window_.reset(); |
| 113 CocoaTest::TearDown(); | 113 CocoaTest::TearDown(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 // Closing the bubble will autorelease the controller. Give callers a keep- | 116 // Closing the bubble will autorelease the controller. Give callers a keep- |
| 117 // alive to run checks after closing. | 117 // alive to run checks after closing. |
| 118 base::scoped_nsobject<BaseBubbleController> ShowBubble() WARN_UNUSED_RESULT { | 118 base::scoped_nsobject<BaseBubbleController> ShowBubble() WARN_UNUSED_RESULT { |
| 119 base::scoped_nsobject<BaseBubbleController> keep_alive( | 119 base::scoped_nsobject<BaseBubbleController> keep_alive( |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 [panel close]; | 388 [panel close]; |
| 389 | 389 |
| 390 EXPECT_FALSE([bubble_window_ attachedSheet]); | 390 EXPECT_FALSE([bubble_window_ attachedSheet]); |
| 391 EXPECT_TRUE([bubble_window_ isVisible]); | 391 EXPECT_TRUE([bubble_window_ isVisible]); |
| 392 EXPECT_FALSE([panel isVisible]); | 392 EXPECT_FALSE([panel isVisible]); |
| 393 | 393 |
| 394 // Now that the sheet is gone, a key status change should close the bubble. | 394 // Now that the sheet is gone, a key status change should close the bubble. |
| 395 SimulateKeyStatusChange(); | 395 SimulateKeyStatusChange(); |
| 396 EXPECT_FALSE([bubble_window_ isVisible]); | 396 EXPECT_FALSE([bubble_window_ isVisible]); |
| 397 } | 397 } |
| OLD | NEW |