| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/scoped_nsobject.h" | 5 #include "base/scoped_nsobject.h" |
| 6 #include "chrome/browser/character_encoding.h" | 6 #include "chrome/browser/character_encoding.h" |
| 7 #include "chrome/browser/cocoa/browser_test_helper.h" | 7 #include "chrome/browser/cocoa/browser_test_helper.h" |
| 8 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 8 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 9 #import "chrome/browser/cocoa/font_language_settings_controller.h" | 9 #import "chrome/browser/cocoa/font_language_settings_controller.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #import "testing/gtest_mac.h" |
| 12 #include "testing/platform_test.h" | 13 #include "testing/platform_test.h" |
| 13 | 14 |
| 14 // The FontLanguageSettingsControllerForTest overrides the getFontFieldOrigin | 15 // The FontLanguageSettingsControllerForTest overrides the getFontFieldOrigin |
| 15 // method to provide a dummy point, so we don't have to actually display the | 16 // method to provide a dummy point, so we don't have to actually display the |
| 16 // window to test the controller. | 17 // window to test the controller. |
| 17 @interface FontLanguageSettingsControllerForTest : | 18 @interface FontLanguageSettingsControllerForTest : |
| 18 FontLanguageSettingsController { | 19 FontLanguageSettingsController { |
| 19 } | 20 } |
| 20 | 21 |
| 21 - (NSPoint)getFontFieldOrigin:(NSTextField*)field | 22 - (NSPoint)getFontFieldOrigin:(NSTextField*)field |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 TEST_F(FontLanguageSettingsControllerTest, UpdateDisplayField) { | 60 TEST_F(FontLanguageSettingsControllerTest, UpdateDisplayField) { |
| 60 NSFont* font = [NSFont fontWithName:@"Times-Roman" size:12.0]; | 61 NSFont* font = [NSFont fontWithName:@"Times-Roman" size:12.0]; |
| 61 scoped_nsobject<NSTextField> field( | 62 scoped_nsobject<NSTextField> field( |
| 62 [[NSTextField alloc] initWithFrame:NSMakeRect(100, 100, 100, 100)]); | 63 [[NSTextField alloc] initWithFrame:NSMakeRect(100, 100, 100, 100)]); |
| 63 scoped_nsobject<NSTextField> label( | 64 scoped_nsobject<NSTextField> label( |
| 64 [[NSTextField alloc] initWithFrame:NSMakeRect(100, 100, 100, 100)]); | 65 [[NSTextField alloc] initWithFrame:NSMakeRect(100, 100, 100, 100)]); |
| 65 [font_controller_ updateDisplayField:field.get() | 66 [font_controller_ updateDisplayField:field.get() |
| 66 withFont:font | 67 withFont:font |
| 67 withLabel:label]; | 68 withLabel:label]; |
| 68 | 69 |
| 69 ASSERT_TRUE([[font fontName] isEqualToString:[[field font] fontName]]); | 70 ASSERT_NSEQ([font fontName], [[field font] fontName]); |
| 70 ASSERT_TRUE([@"Times-Roman, 12" isEqualToString:[field stringValue]]); | 71 ASSERT_NSEQ(@"Times-Roman, 12", [field stringValue]); |
| 71 } | 72 } |
| 72 | 73 |
| 73 TEST_F(FontLanguageSettingsControllerTest, UpdateDisplayFieldNilFont) { | 74 TEST_F(FontLanguageSettingsControllerTest, UpdateDisplayFieldNilFont) { |
| 74 scoped_nsobject<NSTextField> field( | 75 scoped_nsobject<NSTextField> field( |
| 75 [[NSTextField alloc] initWithFrame:NSMakeRect(100, 100, 100, 100)]); | 76 [[NSTextField alloc] initWithFrame:NSMakeRect(100, 100, 100, 100)]); |
| 76 scoped_nsobject<NSTextField> label( | 77 scoped_nsobject<NSTextField> label( |
| 77 [[NSTextField alloc] initWithFrame:NSMakeRect(100, 100, 100, 100)]); | 78 [[NSTextField alloc] initWithFrame:NSMakeRect(100, 100, 100, 100)]); |
| 78 [field setStringValue:@"foo"]; | 79 [field setStringValue:@"foo"]; |
| 79 [font_controller_ updateDisplayField:field.get() | 80 [font_controller_ updateDisplayField:field.get() |
| 80 withFont:nil | 81 withFont:nil |
| 81 withLabel:label]; | 82 withLabel:label]; |
| 82 | 83 |
| 83 ASSERT_TRUE([@"foo" isEqualToString:[field stringValue]]); | 84 ASSERT_NSEQ(@"foo", [field stringValue]); |
| 84 } | 85 } |
| 85 | 86 |
| 86 TEST_F(FontLanguageSettingsControllerTest, UpdateDisplayFieldNilField) { | 87 TEST_F(FontLanguageSettingsControllerTest, UpdateDisplayFieldNilField) { |
| 87 // Don't crash. | 88 // Don't crash. |
| 88 NSFont* font = [NSFont fontWithName:@"Times-Roman" size:12.0]; | 89 NSFont* font = [NSFont fontWithName:@"Times-Roman" size:12.0]; |
| 89 [font_controller_ updateDisplayField:nil withFont:font withLabel:nil]; | 90 [font_controller_ updateDisplayField:nil withFont:font withLabel:nil]; |
| 90 } | 91 } |
| OLD | NEW |