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

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

Issue 24012002: Move Range code to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: d Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
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 <AppKit/AppKit.h> 5 #include <AppKit/AppKit.h>
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #import "content/common/mac/attributed_string_coder.h" 10 #import "content/common/mac/attributed_string_coder.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 NSAttributedString* decoded = EncodeAndDecode(nil); 103 NSAttributedString* decoded = EncodeAndDecode(nil);
104 EXPECT_TRUE(decoded); 104 EXPECT_TRUE(decoded);
105 EXPECT_EQ(0U, [decoded length]); 105 EXPECT_EQ(0U, [decoded length]);
106 } 106 }
107 107
108 TEST_F(AttributedStringCoderTest, OutOfRange) { 108 TEST_F(AttributedStringCoderTest, OutOfRange) {
109 AttributedStringCoder::EncodedString encoded(ASCIIToUTF16("Hello World")); 109 AttributedStringCoder::EncodedString encoded(ASCIIToUTF16("Hello World"));
110 encoded.attributes()->push_back( 110 encoded.attributes()->push_back(
111 AttributedStringCoder::FontAttribute( 111 AttributedStringCoder::FontAttribute(
112 FontDescriptor([NSFont systemFontOfSize:12]), 112 FontDescriptor([NSFont systemFontOfSize:12]),
113 ui::Range(0, 5))); 113 gfx::Range(0, 5)));
114 encoded.attributes()->push_back( 114 encoded.attributes()->push_back(
115 AttributedStringCoder::FontAttribute( 115 AttributedStringCoder::FontAttribute(
116 FontDescriptor([NSFont systemFontOfSize:14]), 116 FontDescriptor([NSFont systemFontOfSize:14]),
117 ui::Range(5, 100))); 117 gfx::Range(5, 100)));
118 encoded.attributes()->push_back( 118 encoded.attributes()->push_back(
119 AttributedStringCoder::FontAttribute( 119 AttributedStringCoder::FontAttribute(
120 FontDescriptor([NSFont systemFontOfSize:16]), 120 FontDescriptor([NSFont systemFontOfSize:16]),
121 ui::Range(100, 5))); 121 gfx::Range(100, 5)));
122 122
123 NSAttributedString* decoded = AttributedStringCoder::Decode(&encoded); 123 NSAttributedString* decoded = AttributedStringCoder::Decode(&encoded);
124 EXPECT_TRUE(decoded); 124 EXPECT_TRUE(decoded);
125 125
126 NSRange range; 126 NSRange range;
127 NSDictionary* attrs = [decoded attributesAtIndex:0 effectiveRange:&range]; 127 NSDictionary* attrs = [decoded attributesAtIndex:0 effectiveRange:&range];
128 EXPECT_NSEQ([NSFont systemFontOfSize:12], 128 EXPECT_NSEQ([NSFont systemFontOfSize:12],
129 [attrs objectForKey:NSFontAttributeName]); 129 [attrs objectForKey:NSFontAttributeName]);
130 EXPECT_TRUE(NSEqualRanges(range, NSMakeRange(0, 5))); 130 EXPECT_TRUE(NSEqualRanges(range, NSMakeRange(0, 5)));
131 131
132 attrs = [decoded attributesAtIndex:5 effectiveRange:&range]; 132 attrs = [decoded attributesAtIndex:5 effectiveRange:&range];
133 EXPECT_FALSE([attrs objectForKey:NSFontAttributeName]); 133 EXPECT_FALSE([attrs objectForKey:NSFontAttributeName]);
134 EXPECT_EQ(0U, [attrs count]); 134 EXPECT_EQ(0U, [attrs count]);
135 } 135 }
OLDNEW
« no previous file with comments | « content/common/mac/attributed_string_coder.mm ('k') | content/common/text_input_client_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698