| 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 #include "extensions/browser/app_window/native_app_window.h" | 5 #include "extensions/browser/app_window/native_app_window.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #import "base/mac/foundation_util.h" | 9 #import "base/mac/foundation_util.h" |
| 10 #import "base/mac/mac_util.h" | 10 #import "base/mac/mac_util.h" |
| 11 #import "base/mac/scoped_cftyperef.h" | 11 #import "base/mac/scoped_cftyperef.h" |
| 12 #import "base/mac/scoped_nsobject.h" | 12 #import "base/mac/scoped_nsobject.h" |
| 13 #import "base/mac/sdk_forward_declarations.h" | 13 #import "base/mac/sdk_forward_declarations.h" |
| 14 #include "chrome/browser/apps/app_browsertest_util.h" | 14 #include "chrome/browser/apps/app_browsertest_util.h" |
| 15 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" | 15 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" |
| 16 #include "chrome/browser/apps/app_shim/test/app_shim_host_manager_test_api_mac.h
" | 16 #include "chrome/browser/apps/app_shim/test/app_shim_host_manager_test_api_mac.h
" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/extensions/app_launch_params.h" | 19 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 20 #include "chrome/browser/ui/extensions/application_launch.h" | 20 #include "chrome/browser/ui/extensions/application_launch.h" |
| 21 #import "chrome/browser/ui/test/scoped_fake_nswindow_main_status.h" | |
| 22 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 23 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/test/test_utils.h" | 23 #include "content/public/test/test_utils.h" |
| 25 #include "extensions/browser/app_window/app_window_registry.h" | 24 #include "extensions/browser/app_window/app_window_registry.h" |
| 26 #include "extensions/common/constants.h" | 25 #include "extensions/common/constants.h" |
| 27 #include "skia/ext/skia_utils_mac.h" | 26 #include "skia/ext/skia_utils_mac.h" |
| 28 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 29 #import "testing/gtest_mac.h" | 28 #import "testing/gtest_mac.h" |
| 30 #import "ui/base/test/nswindow_fullscreen_notification_waiter.h" | 29 #import "ui/base/test/nswindow_fullscreen_notification_waiter.h" |
| 30 #import "ui/base/test/scoped_fake_nswindow_focus.h" |
| 31 #import "ui/base/test/scoped_fake_nswindow_fullscreen.h" | 31 #import "ui/base/test/scoped_fake_nswindow_fullscreen.h" |
| 32 #import "ui/base/test/windowed_nsnotification_observer.h" | 32 #import "ui/base/test/windowed_nsnotification_observer.h" |
| 33 #import "ui/gfx/mac/nswindow_frame_controls.h" | 33 #import "ui/gfx/mac/nswindow_frame_controls.h" |
| 34 | 34 |
| 35 using extensions::AppWindow; | 35 using extensions::AppWindow; |
| 36 using extensions::PlatformAppBrowserTest; | 36 using extensions::PlatformAppBrowserTest; |
| 37 | 37 |
| 38 using ::testing::_; | 38 using ::testing::_; |
| 39 using ::testing::Invoke; | 39 using ::testing::Invoke; |
| 40 using ::testing::Return; | 40 using ::testing::Return; |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 // The window is currently inactive so it should be blue (#0000FF). | 692 // The window is currently inactive so it should be blue (#0000FF). |
| 693 NSColor* expected_color = ColorInBitmapColorSpace(0xFF0000FF, bitmap); | 693 NSColor* expected_color = ColorInBitmapColorSpace(0xFF0000FF, bitmap); |
| 694 NSColor* color = [bitmap colorAtX:half_width y:5]; | 694 NSColor* color = [bitmap colorAtX:half_width y:5]; |
| 695 CGFloat expected_components[4], color_components[4]; | 695 CGFloat expected_components[4], color_components[4]; |
| 696 [expected_color getComponents:expected_components]; | 696 [expected_color getComponents:expected_components]; |
| 697 [color getComponents:color_components]; | 697 [color getComponents:color_components]; |
| 698 EXPECT_NEAR(expected_components[0], color_components[0], 0.01); | 698 EXPECT_NEAR(expected_components[0], color_components[0], 0.01); |
| 699 EXPECT_NEAR(expected_components[1], color_components[1], 0.01); | 699 EXPECT_NEAR(expected_components[1], color_components[1], 0.01); |
| 700 EXPECT_NEAR(expected_components[2], color_components[2], 0.01); | 700 EXPECT_NEAR(expected_components[2], color_components[2], 0.01); |
| 701 | 701 |
| 702 ScopedFakeNSWindowMainStatus fake_main(ns_window); | 702 ui::test::ScopedFakeNSWindowFocus fake_focus; |
| 703 [ns_window makeMainWindow]; |
| 703 | 704 |
| 704 bitmap = ScreenshotNSWindow(ns_window); | 705 bitmap = ScreenshotNSWindow(ns_window); |
| 705 // The window is now active so it should be red (#FF0000). | 706 // The window is now active so it should be red (#FF0000). |
| 706 expected_color = ColorInBitmapColorSpace(0xFFFF0000, bitmap); | 707 expected_color = ColorInBitmapColorSpace(0xFFFF0000, bitmap); |
| 707 color = [bitmap colorAtX:half_width y:5]; | 708 color = [bitmap colorAtX:half_width y:5]; |
| 708 [expected_color getComponents:expected_components]; | 709 [expected_color getComponents:expected_components]; |
| 709 [color getComponents:color_components]; | 710 [color getComponents:color_components]; |
| 710 EXPECT_NEAR(expected_components[0], color_components[0], 0.01); | 711 EXPECT_NEAR(expected_components[0], color_components[0], 0.01); |
| 711 EXPECT_NEAR(expected_components[1], color_components[1], 0.01); | 712 EXPECT_NEAR(expected_components[1], color_components[1], 0.01); |
| 712 EXPECT_NEAR(expected_components[2], color_components[2], 0.01); | 713 EXPECT_NEAR(expected_components[2], color_components[2], 0.01); |
| 713 } | 714 } |
| 714 | 715 |
| 715 INSTANTIATE_TEST_CASE_P(NativeAppWindowCocoaBrowserTestInstance, | 716 INSTANTIATE_TEST_CASE_P(NativeAppWindowCocoaBrowserTestInstance, |
| 716 NativeAppWindowCocoaBrowserTest, | 717 NativeAppWindowCocoaBrowserTest, |
| 717 ::testing::Bool()); | 718 ::testing::Bool()); |
| OLD | NEW |