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

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

Issue 121033002: Update uses of UTF conversions in content/ to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 EXPECT_NSEQ(expected.get(), decoded); 99 EXPECT_NSEQ(expected.get(), decoded);
100 } 100 }
101 101
102 TEST_F(AttributedStringCoderTest, NilString) { 102 TEST_F(AttributedStringCoderTest, NilString) {
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(
110 base::ASCIIToUTF16("Hello World"));
110 encoded.attributes()->push_back( 111 encoded.attributes()->push_back(
111 AttributedStringCoder::FontAttribute( 112 AttributedStringCoder::FontAttribute(
112 FontDescriptor([NSFont systemFontOfSize:12]), 113 FontDescriptor([NSFont systemFontOfSize:12]),
113 gfx::Range(0, 5))); 114 gfx::Range(0, 5)));
114 encoded.attributes()->push_back( 115 encoded.attributes()->push_back(
115 AttributedStringCoder::FontAttribute( 116 AttributedStringCoder::FontAttribute(
116 FontDescriptor([NSFont systemFontOfSize:14]), 117 FontDescriptor([NSFont systemFontOfSize:14]),
117 gfx::Range(5, 100))); 118 gfx::Range(5, 100)));
118 encoded.attributes()->push_back( 119 encoded.attributes()->push_back(
119 AttributedStringCoder::FontAttribute( 120 AttributedStringCoder::FontAttribute(
120 FontDescriptor([NSFont systemFontOfSize:16]), 121 FontDescriptor([NSFont systemFontOfSize:16]),
121 gfx::Range(100, 5))); 122 gfx::Range(100, 5)));
122 123
123 NSAttributedString* decoded = AttributedStringCoder::Decode(&encoded); 124 NSAttributedString* decoded = AttributedStringCoder::Decode(&encoded);
124 EXPECT_TRUE(decoded); 125 EXPECT_TRUE(decoded);
125 126
126 NSRange range; 127 NSRange range;
127 NSDictionary* attrs = [decoded attributesAtIndex:0 effectiveRange:&range]; 128 NSDictionary* attrs = [decoded attributesAtIndex:0 effectiveRange:&range];
128 EXPECT_NSEQ([NSFont systemFontOfSize:12], 129 EXPECT_NSEQ([NSFont systemFontOfSize:12],
129 [attrs objectForKey:NSFontAttributeName]); 130 [attrs objectForKey:NSFontAttributeName]);
130 EXPECT_TRUE(NSEqualRanges(range, NSMakeRange(0, 5))); 131 EXPECT_TRUE(NSEqualRanges(range, NSMakeRange(0, 5)));
131 132
132 attrs = [decoded attributesAtIndex:5 effectiveRange:&range]; 133 attrs = [decoded attributesAtIndex:5 effectiveRange:&range];
133 EXPECT_FALSE([attrs objectForKey:NSFontAttributeName]); 134 EXPECT_FALSE([attrs objectForKey:NSFontAttributeName]);
134 EXPECT_EQ(0U, [attrs count]); 135 EXPECT_EQ(0U, [attrs count]);
135 } 136 }
OLDNEW
« no previous file with comments | « content/common/mac/attributed_string_coder.mm ('k') | content/common/mac/font_descriptor_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698