keyar@chromium.org | c3d5831 | 2012-07-09 18:44:51 +0000 | [diff] [blame] | 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 | #include "Test.h" |
| 8 | #include "picture_utils.h" |
| 9 | #include "SkString.h" |
| 10 | |
| 11 | static void test_filepath_creation(skiatest::Reporter* reporter) { |
| 12 | SkString result; |
| 13 | SkString filename("test"); |
keyar@chromium.org | b630c6c | 2012-07-13 18:43:39 +0000 | [diff] [blame] | 14 | SkString dir("test/path"); |
keyar@chromium.org | c3d5831 | 2012-07-09 18:44:51 +0000 | [diff] [blame] | 15 | sk_tools::make_filepath(&result, dir, filename); |
| 16 | REPORTER_ASSERT(reporter, result.equals("test/path/test")); |
| 17 | } |
| 18 | |
| 19 | static void test_get_basename(skiatest::Reporter* reporter) { |
| 20 | SkString result; |
| 21 | SkString path("/path/basename"); |
| 22 | sk_tools::get_basename(&result, path); |
| 23 | REPORTER_ASSERT(reporter, result.equals("basename")); |
| 24 | |
| 25 | result.reset(); |
| 26 | path.set("/path/dir/"); |
| 27 | sk_tools::get_basename(&result, path); |
| 28 | REPORTER_ASSERT(reporter, result.equals("dir")); |
| 29 | |
| 30 | result.reset(); |
| 31 | path.set("path"); |
| 32 | sk_tools::get_basename(&result, path); |
| 33 | REPORTER_ASSERT(reporter, result.equals("path")); |
| 34 | |
| 35 | #if defined(SK_BUILD_FOR_WIN) |
| 36 | result.reset(); |
| 37 | path.set("path\\winbasename"); |
| 38 | sk_tools::get_basename(&result, path); |
| 39 | REPORTER_ASSERT(reporter, result.equals("winbasename")); |
| 40 | |
| 41 | result.reset(); |
| 42 | path.set("path\\windir\\"); |
| 43 | sk_tools::get_basename(&result, path); |
| 44 | REPORTER_ASSERT(reporter, result.equals("windir")); |
| 45 | #endif |
| 46 | } |
| 47 | |
| 48 | static void TestPictureUtils(skiatest::Reporter* reporter) { |
| 49 | test_filepath_creation(reporter); |
| 50 | test_get_basename(reporter); |
| 51 | } |
| 52 | |
| 53 | #include "TestClassDef.h" |
| 54 | DEFINE_TESTCLASS("PictureUtils", PictureUtilsTestClass, TestPictureUtils) |