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

Side by Side Diff: content/common/mac/font_descriptor_unittest.mm

Issue 8416055: Convert some non-debug logging on content/common to debug logging. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « content/common/handle_enumerator_win.cc ('k') | content/common/mac/font_loader.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/common/mac/font_descriptor.h" 5 #include "content/common/mac/font_descriptor.h"
6 6
7 #include <Cocoa/Cocoa.h> 7 #include <Cocoa/Cocoa.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
12 #include "testing/gtest_mac.h" 12 #include "testing/gtest_mac.h"
13 #include "testing/platform_test.h" 13 #include "testing/platform_test.h"
14 14
15 namespace { 15 namespace {
16 16
17 class FontSerializationTest : public PlatformTest {}; 17 class FontSerializationTest : public PlatformTest {};
18 18
19 const std::string kCourierFontName("Courier"); 19 const std::string kCourierFontName("Courier");
20 20
21 // Compare 2 fonts, make sure they point at the same font definition and have 21 // Compare 2 fonts, make sure they point at the same font definition and have
22 // the same style. Only Bold & Italic style attributes are tested since those 22 // the same style. Only Bold & Italic style attributes are tested since those
23 // are the only ones we care about at the moment. 23 // are the only ones we care about at the moment.
24 bool CompareFonts(NSFont* font1, NSFont* font2) { 24 bool CompareFonts(NSFont* font1, NSFont* font2) {
25 ATSFontRef id1 = CTFontGetPlatformFont(reinterpret_cast<CTFontRef>(font1), 0); 25 ATSFontRef id1 = CTFontGetPlatformFont(reinterpret_cast<CTFontRef>(font1), 0);
26 ATSFontRef id2 = CTFontGetPlatformFont(reinterpret_cast<CTFontRef>(font2), 0); 26 ATSFontRef id2 = CTFontGetPlatformFont(reinterpret_cast<CTFontRef>(font2), 0);
27 27
28 if (id1 != id2) { 28 if (id1 != id2) {
29 LOG(ERROR) << "ATSFontRefs for " 29 DLOG(ERROR) << "ATSFontRefs for "
30 << [[font1 fontName] UTF8String] 30 << [[font1 fontName] UTF8String]
31 << " and " 31 << " and "
32 << [[font2 fontName] UTF8String] 32 << [[font2 fontName] UTF8String]
33 << " are different"; 33 << " are different";
34 return false; 34 return false;
35 } 35 }
36 36
37 CGFloat size1 = [font1 pointSize]; 37 CGFloat size1 = [font1 pointSize];
38 CGFloat size2 = [font2 pointSize]; 38 CGFloat size2 = [font2 pointSize];
39 if (size1 != size2) { 39 if (size1 != size2) {
40 LOG(ERROR) << "font sizes for " 40 DLOG(ERROR) << "font sizes for "
41 << [[font1 fontName] UTF8String] << " (" << size1 << ")" 41 << [[font1 fontName] UTF8String] << " (" << size1 << ")"
42 << "and" 42 << "and"
43 << [[font2 fontName] UTF8String] << " (" << size2 << ")" 43 << [[font2 fontName] UTF8String] << " (" << size2 << ")"
44 << " are different"; 44 << " are different";
45 return false; 45 return false;
46 } 46 }
47 47
48 NSFontTraitMask traits1 = [[NSFontManager sharedFontManager] 48 NSFontTraitMask traits1 = [[NSFontManager sharedFontManager]
49 traitsOfFont:font1]; 49 traitsOfFont:font1];
50 NSFontTraitMask traits2 = [[NSFontManager sharedFontManager] 50 NSFontTraitMask traits2 = [[NSFontManager sharedFontManager]
51 traitsOfFont:font2]; 51 traitsOfFont:font2];
52 52
53 bool is_bold1 = traits1 & NSBoldFontMask; 53 bool is_bold1 = traits1 & NSBoldFontMask;
54 bool is_bold2 = traits2 & NSBoldFontMask; 54 bool is_bold2 = traits2 & NSBoldFontMask;
55 bool is_italic1 = traits1 & NSItalicFontMask; 55 bool is_italic1 = traits1 & NSItalicFontMask;
56 bool is_italic2 = traits2 & NSItalicFontMask; 56 bool is_italic2 = traits2 & NSItalicFontMask;
57 57
58 if (is_bold1 != is_bold2 || is_italic1 != is_italic2) { 58 if (is_bold1 != is_bold2 || is_italic1 != is_italic2) {
59 LOG(ERROR) << "Style information for " 59 DLOG(ERROR) << "Style information for "
60 << [[font1 fontName] UTF8String] 60 << [[font1 fontName] UTF8String]
61 << " and " 61 << " and "
62 << [[font2 fontName] UTF8String] 62 << [[font2 fontName] UTF8String]
63 << " are different"; 63 << " are different";
64 return false; 64 return false;
65 } 65 }
66 66
67 return true; 67 return true;
68 } 68 }
69 69
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 TEST_F(FontSerializationTest, BadParameters) { 105 TEST_F(FontSerializationTest, BadParameters) {
106 EXPECT_NSNE(MakeNSFont(kCourierFontName, 12), nil); 106 EXPECT_NSNE(MakeNSFont(kCourierFontName, 12), nil);
107 EXPECT_NSNE(MakeNSFont(kCourierFontName, std::numeric_limits<float>::min()), 107 EXPECT_NSNE(MakeNSFont(kCourierFontName, std::numeric_limits<float>::min()),
108 nil); 108 nil);
109 EXPECT_NSNE(MakeNSFont(kCourierFontName, 0), nil); 109 EXPECT_NSNE(MakeNSFont(kCourierFontName, 0), nil);
110 EXPECT_NSNE(MakeNSFont(kCourierFontName, std::numeric_limits<float>::max()), 110 EXPECT_NSNE(MakeNSFont(kCourierFontName, std::numeric_limits<float>::max()),
111 nil); 111 nil);
112 } 112 }
113 113
114 } // namespace 114 } // namespace
OLDNEW
« no previous file with comments | « content/common/handle_enumerator_win.cc ('k') | content/common/mac/font_loader.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698