| 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 icon:icon_]; | 169 icon:icon_]; |
| 170 EXPECT_TRUE(controller); | 170 EXPECT_TRUE(controller); |
| 171 | 171 |
| 172 // Initialize window without having to calculate tabstrip locations. | 172 // Initialize window without having to calculate tabstrip locations. |
| 173 [controller initializeWindow]; | 173 [controller initializeWindow]; |
| 174 EXPECT_TRUE([controller window]); | 174 EXPECT_TRUE([controller window]); |
| 175 | 175 |
| 176 int height = [controller calculateWindowHeight]; | 176 int height = [controller calculateWindowHeight]; |
| 177 // Height should equal the vertical padding + height of all messages. | 177 // Height should equal the vertical padding + height of all messages. |
| 178 int correctHeight = 2 * extension_installed_bubble::kOuterVerticalMargin + | 178 int correctHeight = 2 * extension_installed_bubble::kOuterVerticalMargin + |
| 179 extension_installed_bubble::kInnerVerticalMargin + | 179 2 * extension_installed_bubble::kInnerVerticalMargin + |
| 180 [controller getExtensionInstalledMsgFrame].size.height + | 180 [controller getExtensionInstalledMsgFrame].size.height + |
| 181 [controller getExtensionInstalledInfoMsgFrame].size.height; | 181 [controller getExtensionInstalledInfoMsgFrame].size.height + |
| 182 [controller getExtraInfoMsgFrame].size.height; |
| 182 EXPECT_EQ(height, correctHeight); | 183 EXPECT_EQ(height, correctHeight); |
| 183 | 184 |
| 184 [controller setMessageFrames:height]; | 185 [controller setMessageFrames:height]; |
| 185 NSRect msg3Frame = [controller getExtensionInstalledInfoMsgFrame]; | 186 NSRect msg3Frame = [controller getExtensionInstalledInfoMsgFrame]; |
| 186 // Bottom message should start kOuterVerticalMargin pixels above window edge. | 187 // Bottom message should start kOuterVerticalMargin pixels above window edge. |
| 187 EXPECT_EQ(msg3Frame.origin.y, | 188 EXPECT_EQ(msg3Frame.origin.y, |
| 188 extension_installed_bubble::kOuterVerticalMargin); | 189 extension_installed_bubble::kOuterVerticalMargin); |
| 190 NSRect msg2Frame = [controller getExtraInfoMsgFrame]; |
| 191 // Pageaction message should be kInnerVerticalMargin pixels above bottom msg. |
| 192 EXPECT_EQ(NSMinY(msg2Frame), |
| 193 NSMaxY(msg3Frame) + |
| 194 extension_installed_bubble::kInnerVerticalMargin); |
| 189 NSRect msg1Frame = [controller getExtensionInstalledMsgFrame]; | 195 NSRect msg1Frame = [controller getExtensionInstalledMsgFrame]; |
| 190 // Top message should start kInnerVerticalMargin pixels above top of | 196 // Top message should be kInnerVerticalMargin pixels above BrowserAction msg. |
| 191 // extensionInstalled message, because page action message is hidden. | 197 EXPECT_EQ(NSMinY(msg1Frame), |
| 192 EXPECT_EQ(msg1Frame.origin.y, | 198 NSMaxY(msg2Frame) + |
| 193 msg3Frame.origin.y + msg3Frame.size.height + | |
| 194 extension_installed_bubble::kInnerVerticalMargin); | 199 extension_installed_bubble::kInnerVerticalMargin); |
| 195 | 200 |
| 196 [controller close]; | 201 [controller close]; |
| 197 } | 202 } |
| 198 | 203 |
| 199 TEST_F(ExtensionInstalledBubbleControllerTest, ParentClose) { | 204 TEST_F(ExtensionInstalledBubbleControllerTest, ParentClose) { |
| 200 extension_ = CreateExtension(extension_installed_bubble::kBrowserAction); | 205 extension_ = CreateExtension(extension_installed_bubble::kBrowserAction); |
| 201 ExtensionInstalledBubbleControllerForTest* controller = | 206 ExtensionInstalledBubbleControllerForTest* controller = |
| 202 [[ExtensionInstalledBubbleControllerForTest alloc] | 207 [[ExtensionInstalledBubbleControllerForTest alloc] |
| 203 initWithParentWindow:window_ | 208 initWithParentWindow:window_ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 223 // The bubble window goes from visible to not-visible. | 228 // The bubble window goes from visible to not-visible. |
| 224 EXPECT_TRUE([bubbleWindow isVisible]); | 229 EXPECT_TRUE([bubbleWindow isVisible]); |
| 225 [window_ close]; | 230 [window_ close]; |
| 226 EXPECT_FALSE([bubbleWindow isVisible]); | 231 EXPECT_FALSE([bubbleWindow isVisible]); |
| 227 | 232 |
| 228 [[NSNotificationCenter defaultCenter] removeObserver:observer]; | 233 [[NSNotificationCenter defaultCenter] removeObserver:observer]; |
| 229 | 234 |
| 230 // Check that the appropriate notification was received. | 235 // Check that the appropriate notification was received. |
| 231 EXPECT_OCMOCK_VERIFY(observer); | 236 EXPECT_OCMOCK_VERIFY(observer); |
| 232 } | 237 } |
| OLD | NEW |