Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1950)

Side by Side Diff: chrome/browser/ui/cocoa/apps/native_app_window_cocoa_browsertest.mm

Issue 1053303003: [MacViews] Implement colored window frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missed a few things. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/scoped_objc_class_swizzler.h"
tapted 2015/05/12 06:15:43 is this used?
jackhou1 2015/05/14 02:59:13 Nope, removed.
15 #import "base/mac/sdk_forward_declarations.h"
14 #include "chrome/browser/apps/app_browsertest_util.h" 16 #include "chrome/browser/apps/app_browsertest_util.h"
15 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #import "chrome/browser/ui/cocoa/apps/scoped_fake_nswindow_main_status.h"
16 #include "chrome/browser/ui/extensions/app_launch_params.h" 19 #include "chrome/browser/ui/extensions/app_launch_params.h"
17 #include "chrome/browser/ui/extensions/application_launch.h" 20 #include "chrome/browser/ui/extensions/application_launch.h"
18 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
19 #include "content/public/test/test_utils.h" 22 #include "content/public/test/test_utils.h"
20 #include "extensions/browser/app_window/app_window_registry.h" 23 #include "extensions/browser/app_window/app_window_registry.h"
21 #include "extensions/common/constants.h" 24 #include "extensions/common/constants.h"
22 25
23 using extensions::PlatformAppBrowserTest; 26 using extensions::PlatformAppBrowserTest;
24 27
25 namespace { 28 namespace {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 300
298 } // namespace 301 } // namespace
299 302
300 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, Controls) { 303 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, Controls) {
301 TestControls(CreateTestAppWindow("{}")); 304 TestControls(CreateTestAppWindow("{}"));
302 } 305 }
303 306
304 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, ControlsFrameless) { 307 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, ControlsFrameless) {
305 TestControls(CreateTestAppWindow("{\"frame\": \"none\"}")); 308 TestControls(CreateTestAppWindow("{\"frame\": \"none\"}"));
306 } 309 }
310
311 // Test that the colored frames have the correct color when active and inactive.
312 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaBrowserTest, FrameColor) {
313 extensions::AppWindow* app_window = CreateTestAppWindow(
314 "{\"frame\": {\"color\": \"#FF0000\", \"inactiveColor\": \"#0000FF\"}}");
315 NSWindow* ns_window = app_window->GetNativeWindow();
316 // Disable color correction so we can read unmodified values from the bitmap.
317 [ns_window setColorSpace:[NSColorSpace sRGBColorSpace]];
318
319 NSView* frame_view = [[ns_window contentView] superview];
320 NSRect bounds = [frame_view bounds];
321 NSBitmapImageRep* bitmap =
322 [frame_view bitmapImageRepForCachingDisplayInRect:bounds];
323
324 [frame_view cacheDisplayInRect:bounds toBitmapImageRep:bitmap];
325 NSColor* color = [bitmap colorAtX:NSMidX(bounds) y:5];
326 EXPECT_EQ(0, [color redComponent]);
327 EXPECT_EQ(0, [color greenComponent]);
328 EXPECT_EQ(1, [color blueComponent]);
329
330 ScopedFakeNSWindowMainStatus fake_main(ns_window);
331
332 [frame_view cacheDisplayInRect:bounds toBitmapImageRep:bitmap];
333 color = [bitmap colorAtX:NSMidX(bounds) y:5];
334 EXPECT_EQ(1, [color redComponent]);
335 EXPECT_EQ(0, [color greenComponent]);
336 EXPECT_EQ(0, [color blueComponent]);
337 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698