Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // This file tests whichever implementation of NativeAppWindow is used. | |
|
tapted
2015/05/06 03:15:42
btw - have you been able to try out the views vers
jackhou1
2015/05/12 05:39:04
Yeah I had to comment out a bunch of test files in
| |
| 6 // I.e. it could be NativeAppWindowCocoa or ChromeNativeAppWindowViewsMac. | |
| 7 #include "extensions/browser/app_window/native_app_window.h" | |
| 8 | |
| 9 #import <Cocoa/Cocoa.h> | |
| 10 | |
| 11 #include "base/mac/mac_util.h" | |
|
tapted
2015/05/06 03:15:42
is this used?
jackhou1
2015/05/12 05:39:04
Moved back to browser_test.
| |
| 12 #include "base/mac/scoped_nsobject.h" | |
|
tapted
2015/05/06 03:15:42
nit: import
jackhou1
2015/05/12 05:39:05
Done.
| |
| 13 #include "base/mac/sdk_forward_declarations.h" | |
|
tapted
2015/05/06 03:15:42
import
jackhou1
2015/05/12 05:39:04
Done.
| |
| 14 #include "chrome/browser/apps/app_browsertest_util.h" | |
| 15 #include "content/public/test/test_utils.h" | |
|
tapted
2015/05/06 03:15:42
is this used?
jackhou1
2015/05/12 05:39:04
Moved back to browser_test.
| |
| 16 #include "extensions/common/constants.h" | |
| 17 #import "skia/ext/skia_utils_mac.h" | |
| 18 | |
| 19 namespace { | |
| 20 | |
| 21 class NativeAppWindowCocoaInteractiveTest | |
|
tapted
2015/05/06 03:15:41
If the harness is empty, you can instead do
`usin
jackhou1
2015/05/12 05:39:04
Moved back to browser_test.
| |
| 22 : public extensions::PlatformAppBrowserTest { | |
| 23 protected: | |
| 24 NativeAppWindowCocoaInteractiveTest() {} | |
| 25 | |
| 26 private: | |
| 27 DISALLOW_COPY_AND_ASSIGN(NativeAppWindowCocoaInteractiveTest); | |
| 28 }; | |
| 29 | |
| 30 } // namespace | |
| 31 | |
| 32 IN_PROC_BROWSER_TEST_F(NativeAppWindowCocoaInteractiveTest, FrameColor) { | |
|
tapted
2015/05/06 03:15:42
needs a comment saying what the test is for
jackhou1
2015/05/12 05:39:05
Done.
| |
| 33 extensions::AppWindow* app_window = CreateTestAppWindow( | |
| 34 "{\"frame\": {\"color\": \"#FF0000\", \"inactiveColor\": \"#0000FF\"}}"); | |
| 35 NSWindow* ns_window = app_window->GetNativeWindow(); | |
| 36 // Disable color correction so we can read unmodified values from the bitmap. | |
| 37 [ns_window setColorSpace:[NSColorSpace sRGBColorSpace]]; | |
| 38 | |
| 39 NSView* frame_view = [[ns_window contentView] superview]; | |
| 40 NSRect bounds = [frame_view bounds]; | |
| 41 NSBitmapImageRep* bitmap = | |
| 42 [frame_view bitmapImageRepForCachingDisplayInRect:bounds]; | |
| 43 | |
| 44 NSColor* blueColor = gfx::SkColorToSRGBNSColor(SK_ColorBLUE); | |
|
tapted
2015/05/06 03:15:42
blueColor -> blue_color
jackhou1
2015/05/12 05:39:04
Done.
| |
| 45 [frame_view cacheDisplayInRect:bounds toBitmapImageRep:bitmap]; | |
| 46 NSColor* color = [bitmap colorAtX:(bounds.size.width / 2)y:5]; | |
|
tapted
2015/05/06 03:15:42
space before `y:`, also below
tapted
2015/05/06 03:15:42
bounds.size.width/2 -> NSMidX(bounds)
jackhou1
2015/05/12 05:39:04
Done.
jackhou1
2015/05/12 05:39:04
Done.
| |
| 47 EXPECT_EQ([blueColor redComponent], [color redComponent]); | |
| 48 EXPECT_EQ([blueColor greenComponent], [color greenComponent]); | |
| 49 EXPECT_EQ([blueColor blueComponent], [color blueComponent]); | |
|
tapted
2015/05/06 03:15:42
I don't find these checks as convincing as just re
jackhou1
2015/05/12 05:39:05
Done.
tapted
2015/05/12 06:15:43
You missed this i think
jackhou1
2015/05/14 02:59:13
NSColor components are CGFloats, so it's 1 instead
tapted
2015/05/14 04:23:50
Ah, can you comment - it should say the values cor
jackhou1
2015/05/14 06:20:40
Done.
| |
| 50 | |
| 51 [ns_window makeKeyAndOrderFront:nil]; | |
|
tapted
2015/05/06 03:15:42
I think this updates isMain/Key asynchronously, so
jackhou1
2015/05/12 05:39:04
ScopedFakeWindowMainStatus works. Moved to its own
| |
| 52 [NSApp activateIgnoringOtherApps:YES]; | |
| 53 NSColor* redColor = gfx::SkColorToSRGBNSColor(SK_ColorRED); | |
|
tapted
2015/05/06 03:15:42
red_color
jackhou1
2015/05/12 05:39:04
Done.
| |
| 54 [frame_view cacheDisplayInRect:bounds toBitmapImageRep:bitmap]; | |
| 55 color = [bitmap colorAtX:(bounds.size.width / 2)y:5]; | |
| 56 EXPECT_EQ([redColor redComponent], [color redComponent]); | |
| 57 EXPECT_EQ([redColor greenComponent], [color greenComponent]); | |
| 58 EXPECT_EQ([redColor blueComponent], [color blueComponent]); | |
| 59 } | |
| OLD | NEW |