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