| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This file tests whichever implementation of NativeAppWindow is used. | 5 // This file tests whichever implementation of NativeAppWindow is used. |
| 6 // I.e. it could be NativeAppWindowCocoa or ChromeNativeAppWindowViewsMac. | 6 // I.e. it could be NativeAppWindowCocoa or ChromeNativeAppWindowViewsMac. |
| 7 #include "extensions/browser/app_window/native_app_window.h" | 7 #include "extensions/browser/app_window/native_app_window.h" |
| 8 | 8 |
| 9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
| 10 | 10 |
| 11 #include "base/mac/mac_util.h" | 11 #import "base/mac/foundation_util.h" |
| 12 #include "base/mac/scoped_nsobject.h" | 12 #import "base/mac/mac_util.h" |
| 13 #include "base/mac/sdk_forward_declarations.h" | 13 #import "base/mac/scoped_nsobject.h" |
| 14 #import "base/mac/sdk_forward_declarations.h" |
| 14 #include "chrome/browser/apps/app_browsertest_util.h" | 15 #include "chrome/browser/apps/app_browsertest_util.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/extensions/app_launch_params.h" | 17 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 17 #include "chrome/browser/ui/extensions/application_launch.h" | 18 #include "chrome/browser/ui/extensions/application_launch.h" |
| 19 #import "chrome/browser/ui/test/scoped_fake_nswindow_main_status.h" |
| 18 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 19 #include "content/public/test/test_utils.h" | 21 #include "content/public/test/test_utils.h" |
| 20 #include "extensions/browser/app_window/app_window_registry.h" | 22 #include "extensions/browser/app_window/app_window_registry.h" |
| 21 #include "extensions/common/constants.h" | 23 #include "extensions/common/constants.h" |
| 22 | 24 |
| 23 using extensions::PlatformAppBrowserTest; | 25 using extensions::PlatformAppBrowserTest; |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 27 class NativeAppWindowCocoaBrowserTest : public PlatformAppBrowserTest { | 29 class NativeAppWindowCocoaBrowserTest : public PlatformAppBrowserTest { |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 | 299 |
| 298 } // namespace | 300 } // namespace |
| 299 | 301 |
| 300 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, Controls) { | 302 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, Controls) { |
| 301 TestControls(CreateTestAppWindow("{}")); | 303 TestControls(CreateTestAppWindow("{}")); |
| 302 } | 304 } |
| 303 | 305 |
| 304 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, ControlsFrameless) { | 306 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, ControlsFrameless) { |
| 305 TestControls(CreateTestAppWindow("{\"frame\": \"none\"}")); | 307 TestControls(CreateTestAppWindow("{\"frame\": \"none\"}")); |
| 306 } | 308 } |
| 309 |
| 310 // Test that the colored frames have the correct color when active and inactive. |
| 311 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, FrameColor) { |
| 312 extensions::AppWindow* app_window = CreateTestAppWindow( |
| 313 "{\"frame\": {\"color\": \"#FF0000\", \"inactiveColor\": \"#0000FF\"}}"); |
| 314 NSWindow* ns_window = app_window->GetNativeWindow(); |
| 315 // Disable color correction so we can read unmodified values from the bitmap. |
| 316 [ns_window setColorSpace:[NSColorSpace sRGBColorSpace]]; |
| 317 |
| 318 NSView* frame_view = [[ns_window contentView] superview]; |
| 319 NSRect bounds = [frame_view bounds]; |
| 320 NSBitmapImageRep* bitmap = |
| 321 [frame_view bitmapImageRepForCachingDisplayInRect:bounds]; |
| 322 |
| 323 [frame_view cacheDisplayInRect:bounds toBitmapImageRep:bitmap]; |
| 324 NSColor* color = [bitmap colorAtX:NSMidX(bounds) y:5]; |
| 325 EXPECT_EQ(0, [color redComponent]); |
| 326 EXPECT_EQ(0, [color greenComponent]); |
| 327 EXPECT_EQ(1, [color blueComponent]); |
| 328 |
| 329 ScopedFakeNSWindowMainStatus fake_main(ns_window); |
| 330 |
| 331 [frame_view cacheDisplayInRect:bounds toBitmapImageRep:bitmap]; |
| 332 color = [bitmap colorAtX:NSMidX(bounds) y:5]; |
| 333 EXPECT_EQ(1, [color redComponent]); |
| 334 EXPECT_EQ(0, [color greenComponent]); |
| 335 EXPECT_EQ(0, [color blueComponent]); |
| 336 } |
| OLD | NEW |