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 | */ |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 7 | |
keyar@chromium.org | c3d5831 | 2012-07-09 18:44:51 +0000 | [diff] [blame] | 8 | #include "Test.h" |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 9 | #include "TestClassDef.h" |
keyar@chromium.org | c3d5831 | 2012-07-09 18:44:51 +0000 | [diff] [blame] | 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"); |
keyar@chromium.org | b630c6c | 2012-07-13 18:43:39 +0000 | [diff] [blame] | 16 | SkString dir("test/path"); |
keyar@chromium.org | c3d5831 | 2012-07-09 18:44:51 +0000 | [diff] [blame] | 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 | |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 50 | DEF_TEST(PictureUtils, reporter) { |
keyar@chromium.org | c3d5831 | 2012-07-09 18:44:51 +0000 | [diff] [blame] | 51 | test_filepath_creation(reporter); |
| 52 | test_get_basename(reporter); |
| 53 | } |