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

Unified Diff: chrome/browser/ui/cocoa/apps/native_app_window_cocoa_interactive_uitest.mm

Issue 1053303003: [MacViews] Implement colored window frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/apps/native_app_window_cocoa_interactive_uitest.mm
diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa_interactive_uitest.mm b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa_interactive_uitest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..bffc99b288418d755fb35296b94325229cb2b3e5
--- /dev/null
+++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa_interactive_uitest.mm
@@ -0,0 +1,59 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// 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
+// I.e. it could be NativeAppWindowCocoa or ChromeNativeAppWindowViewsMac.
+#include "extensions/browser/app_window/native_app_window.h"
+
+#import <Cocoa/Cocoa.h>
+
+#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.
+#include "base/mac/scoped_nsobject.h"
tapted 2015/05/06 03:15:42 nit: import
jackhou1 2015/05/12 05:39:05 Done.
+#include "base/mac/sdk_forward_declarations.h"
tapted 2015/05/06 03:15:42 import
jackhou1 2015/05/12 05:39:04 Done.
+#include "chrome/browser/apps/app_browsertest_util.h"
+#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.
+#include "extensions/common/constants.h"
+#import "skia/ext/skia_utils_mac.h"
+
+namespace {
+
+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.
+ : public extensions::PlatformAppBrowserTest {
+ protected:
+ NativeAppWindowCocoaInteractiveTest() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(NativeAppWindowCocoaInteractiveTest);
+};
+
+} // namespace
+
+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.
+ extensions::AppWindow* app_window = CreateTestAppWindow(
+ "{\"frame\": {\"color\": \"#FF0000\", \"inactiveColor\": \"#0000FF\"}}");
+ NSWindow* ns_window = app_window->GetNativeWindow();
+ // Disable color correction so we can read unmodified values from the bitmap.
+ [ns_window setColorSpace:[NSColorSpace sRGBColorSpace]];
+
+ NSView* frame_view = [[ns_window contentView] superview];
+ NSRect bounds = [frame_view bounds];
+ NSBitmapImageRep* bitmap =
+ [frame_view bitmapImageRepForCachingDisplayInRect:bounds];
+
+ NSColor* blueColor = gfx::SkColorToSRGBNSColor(SK_ColorBLUE);
tapted 2015/05/06 03:15:42 blueColor -> blue_color
jackhou1 2015/05/12 05:39:04 Done.
+ [frame_view cacheDisplayInRect:bounds toBitmapImageRep:bitmap];
+ 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.
+ EXPECT_EQ([blueColor redComponent], [color redComponent]);
+ EXPECT_EQ([blueColor greenComponent], [color greenComponent]);
+ 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.
+
+ [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
+ [NSApp activateIgnoringOtherApps:YES];
+ NSColor* redColor = gfx::SkColorToSRGBNSColor(SK_ColorRED);
tapted 2015/05/06 03:15:42 red_color
jackhou1 2015/05/12 05:39:04 Done.
+ [frame_view cacheDisplayInRect:bounds toBitmapImageRep:bitmap];
+ color = [bitmap colorAtX:(bounds.size.width / 2)y:5];
+ EXPECT_EQ([redColor redComponent], [color redComponent]);
+ EXPECT_EQ([redColor greenComponent], [color greenComponent]);
+ EXPECT_EQ([redColor blueComponent], [color blueComponent]);
+}

Powered by Google App Engine
This is Rietveld 408576698