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

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* font =
bungeman-skia 2013/05/03 14:11:41 I think this just needs to be SkSafeUnref(paint.s
76 SkTypeface::CreateFromName("Georgia", SkTypeface::kNormal);
77 if (NULL == font) {
78 printf("create font failed.\n");
79 return;
80 }
81 paint.setTypeface(font)->unref();
76 82
77 SkIRect origRect = SkIRect::MakeWH(64, 64); 83 SkIRect origRect = SkIRect::MakeWH(64, 64);
78 SkBitmap origBitmap; 84 SkBitmap origBitmap;
79 create(&origBitmap, origRect, SkBitmap::kARGB_8888_Config); 85 create(&origBitmap, origRect, SkBitmap::kARGB_8888_Config);
80 SkCanvas origCanvas(origBitmap); 86 SkCanvas origCanvas(origBitmap);
81 87
82 SkIRect streamRect = SkIRect::MakeWH(64, 64); 88 SkIRect streamRect = SkIRect::MakeWH(64, 64);
83 SkBitmap streamBitmap; 89 SkBitmap streamBitmap;
84 create(&streamBitmap, streamRect, SkBitmap::kARGB_8888_Config); 90 create(&streamBitmap, streamRect, SkBitmap::kARGB_8888_Config);
85 SkCanvas streamCanvas(streamBitmap); 91 SkCanvas streamCanvas(streamBitmap);
(...skipping 19 matching lines...) Expand all
105 111
106 REPORTER_ASSERT(reporter, 112 REPORTER_ASSERT(reporter,
107 compare(origBitmap, origRect, streamBitmap, streamRect)) ; 113 compare(origBitmap, origRect, streamBitmap, streamRect)) ;
108 } 114 }
109 //Make sure the typeface is deleted and removed. 115 //Make sure the typeface is deleted and removed.
110 SkGraphics::PurgeFontCache(); 116 SkGraphics::PurgeFontCache();
111 } 117 }
112 118
113 #include "TestClassDef.h" 119 #include "TestClassDef.h"
114 DEFINE_TESTCLASS("FontHost::CreateTypefaceFromStream", FontHostStreamTestClass, test_fontHostStream) 120 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