| OLD | NEW |
| 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/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 70 // Create an NSFont via a FontDescriptor object. | 70 // Create an NSFont via a FontDescriptor object. |
| 71 NSFont* MakeNSFont(const std::string& font_name, float font_point_size) { | 71 NSFont* MakeNSFont(const std::string& font_name, float font_point_size) { |
| 72 FontDescriptor desc; | 72 FontDescriptor desc; |
| 73 desc.font_name = UTF8ToUTF16(font_name); | 73 desc.font_name = base::UTF8ToUTF16(font_name); |
| 74 desc.font_point_size = font_point_size; | 74 desc.font_point_size = font_point_size; |
| 75 return desc.ToNSFont(); | 75 return desc.ToNSFont(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Verify that serialization and deserialization of fonts with various styles | 78 // Verify that serialization and deserialization of fonts with various styles |
| 79 // is performed correctly by FontDescriptor. | 79 // is performed correctly by FontDescriptor. |
| 80 TEST_F(FontSerializationTest, StyledFonts) { | 80 TEST_F(FontSerializationTest, StyledFonts) { |
| 81 NSFont* plain_font = [NSFont systemFontOfSize:12.0]; | 81 NSFont* plain_font = [NSFont systemFontOfSize:12.0]; |
| 82 ASSERT_TRUE(plain_font != nil); | 82 ASSERT_TRUE(plain_font != nil); |
| 83 FontDescriptor desc_plain(plain_font); | 83 FontDescriptor desc_plain(plain_font); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 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 |
| OLD | NEW |