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.
5 #import "ui/base/cocoa/nscolor_additions.h"
7 #include "base/mac/scoped_cftyperef.h"
8 #include "testing/platform_test.h"
10 typedef PlatformTest NSColorChromeAdditionsTest;
12 TEST_F(NSColorChromeAdditionsTest, ConvertColorWithTwoComponents) {
13 NSColor* nsColor = [NSColor colorWithCalibratedWhite:0.5 alpha:0.5];
14 base::ScopedCFTypeRef<CGColorRef> cgColor(CGColorCreateGenericGray(0.5, 0.5));
15 EXPECT_TRUE(CFEqual(cgColor, [nsColor cr_CGColor]));
18 TEST_F(NSColorChromeAdditionsTest, ConvertColorWithFourComponents) {
20 [NSColor colorWithCalibratedRed:0.1 green:0.2 blue:0.3 alpha:0.4];
21 base::ScopedCFTypeRef<CGColorRef> cgColor(
22 CGColorCreateGenericRGB(0.1, 0.2, 0.3, 0.4));
23 EXPECT_TRUE(CFEqual(cgColor, [nsColor cr_CGColor]));