blob: bb01bc902f4a870bc14a828ca4408e9e80889330 [file] [log] [blame]
keyar@chromium.orgc3d58312012-07-09 18:44:51 +00001/*
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
11static void test_filepath_creation(skiatest::Reporter* reporter) {
12 SkString result;
13 SkString filename("test");
keyar@chromium.orgb630c6c2012-07-13 18:43:39 +000014 SkString dir("test/path");
keyar@chromium.orgc3d58312012-07-09 18:44:51 +000015 sk_tools::make_filepath(&result, dir, filename);
16 REPORTER_ASSERT(reporter, result.equals("test/path/test"));
17}
18
19static 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
48static void TestPictureUtils(skiatest::Reporter* reporter) {
49 test_filepath_creation(reporter);
50 test_get_basename(reporter);
51}
52
53#include "TestClassDef.h"
54DEFINE_TESTCLASS("PictureUtils", PictureUtilsTestClass, TestPictureUtils)