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

Side by Side Diff: tests/FontHostStreamTest.cpp

Issue 14907005: Check whether font creation is failed to avoid segment fault. (Closed) Base URL: http://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "SkTypes.h" 7 #include "SkTypes.h"
8 8
9 #include "Test.h" 9 #include "Test.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return true; 65 return true;
66 } 66 }
67 67
68 static void test_fontHostStream(skiatest::Reporter* reporter) { 68 static void test_fontHostStream(skiatest::Reporter* reporter) {
69 69
70 { 70 {
71 SkPaint paint; 71 SkPaint paint;
72 paint.setColor(SK_ColorGRAY); 72 paint.setColor(SK_ColorGRAY);
73 paint.setTextSize(SkIntToScalar(30)); 73 paint.setTextSize(SkIntToScalar(30));
74 74
75 paint.setTypeface(SkTypeface::CreateFromName("Georgia", SkTypeface::kNor mal))->unref(); 75 SkTypeface* fTypeface = SkTypeface::CreateFromName("Georgia",
76 SkTypeface::kNormal);
77 SkSafeUnref(paint.setTypeface(fTypeface));
76 78
77 SkIRect origRect = SkIRect::MakeWH(64, 64); 79 SkIRect origRect = SkIRect::MakeWH(64, 64);
78 SkBitmap origBitmap; 80 SkBitmap origBitmap;
79 create(&origBitmap, origRect, SkBitmap::kARGB_8888_Config); 81 create(&origBitmap, origRect, SkBitmap::kARGB_8888_Config);
80 SkCanvas origCanvas(origBitmap); 82 SkCanvas origCanvas(origBitmap);
81 83
82 SkIRect streamRect = SkIRect::MakeWH(64, 64); 84 SkIRect streamRect = SkIRect::MakeWH(64, 64);
83 SkBitmap streamBitmap; 85 SkBitmap streamBitmap;
84 create(&streamBitmap, streamRect, SkBitmap::kARGB_8888_Config); 86 create(&streamBitmap, streamRect, SkBitmap::kARGB_8888_Config);
85 SkCanvas streamCanvas(streamBitmap); 87 SkCanvas streamCanvas(streamBitmap);
(...skipping 19 matching lines...) Expand all
105 107
106 REPORTER_ASSERT(reporter, 108 REPORTER_ASSERT(reporter,
107 compare(origBitmap, origRect, streamBitmap, streamRect)) ; 109 compare(origBitmap, origRect, streamBitmap, streamRect)) ;
108 } 110 }
109 //Make sure the typeface is deleted and removed. 111 //Make sure the typeface is deleted and removed.
110 SkGraphics::PurgeFontCache(); 112 SkGraphics::PurgeFontCache();
111 } 113 }
112 114
113 #include "TestClassDef.h" 115 #include "TestClassDef.h"
114 DEFINE_TESTCLASS("FontHost::CreateTypefaceFromStream", FontHostStreamTestClass, test_fontHostStream) 116 DEFINE_TESTCLASS("FontHost::CreateTypefaceFromStream", FontHostStreamTestClass, test_fontHostStream)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698