1 /* 2 * Copyright 2012 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "Test.h" 9 #include "TestClassDef.h" 10 #include "picture_utils.h" 11 #include "SkString.h" 12 13 static void test_filepath_creation(skiatest::Reporter* reporter) { 14 SkString result; 15 SkString filename("test"); 16 SkString dir("test/path"); 17 sk_tools::make_filepath(&result, dir, filename); 18 REPORTER_ASSERT(reporter, result.equals("test/path/test")); 19 } 20 21 static void test_get_basename(skiatest::Reporter* reporter) { 22 SkString result; 23 SkString path("/path/basename"); 24 sk_tools::get_basename(&result, path); 25 REPORTER_ASSERT(reporter, result.equals("basename")); 26 27 result.reset(); 28 path.set("/path/dir/"); 29 sk_tools::get_basename(&result, path); 30 REPORTER_ASSERT(reporter, result.equals("dir")); 31 32 result.reset(); 33 path.set("path"); 34 sk_tools::get_basename(&result, path); 35 REPORTER_ASSERT(reporter, result.equals("path")); 36 37 #if defined(SK_BUILD_FOR_WIN) 38 result.reset(); 39 path.set("path\\winbasename"); 40 sk_tools::get_basename(&result, path); 41 REPORTER_ASSERT(reporter, result.equals("winbasename")); 42 43 result.reset(); 44 path.set("path\\windir\\"); 45 sk_tools::get_basename(&result, path); 46 REPORTER_ASSERT(reporter, result.equals("windir")); 47 #endif 48 } 49 50 DEF_TEST(PictureUtils, reporter) { 51 test_filepath_creation(reporter); 52 test_get_basename(reporter); 53 } 54