2012-07-09 18:44:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2013-12-12 21:11:12 +00:00
|
|
|
|
2012-07-09 18:44:51 +00:00
|
|
|
#include "Test.h"
|
2013-12-12 21:11:12 +00:00
|
|
|
#include "TestClassDef.h"
|
2012-07-09 18:44:51 +00:00
|
|
|
#include "picture_utils.h"
|
|
|
|
#include "SkString.h"
|
|
|
|
|
|
|
|
static void test_filepath_creation(skiatest::Reporter* reporter) {
|
|
|
|
SkString result;
|
|
|
|
SkString filename("test");
|
2012-07-13 18:43:39 +00:00
|
|
|
SkString dir("test/path");
|
2012-07-09 18:44:51 +00:00
|
|
|
sk_tools::make_filepath(&result, dir, filename);
|
|
|
|
REPORTER_ASSERT(reporter, result.equals("test/path/test"));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_get_basename(skiatest::Reporter* reporter) {
|
|
|
|
SkString result;
|
|
|
|
SkString path("/path/basename");
|
|
|
|
sk_tools::get_basename(&result, path);
|
|
|
|
REPORTER_ASSERT(reporter, result.equals("basename"));
|
|
|
|
|
|
|
|
result.reset();
|
|
|
|
path.set("/path/dir/");
|
|
|
|
sk_tools::get_basename(&result, path);
|
|
|
|
REPORTER_ASSERT(reporter, result.equals("dir"));
|
|
|
|
|
|
|
|
result.reset();
|
|
|
|
path.set("path");
|
|
|
|
sk_tools::get_basename(&result, path);
|
|
|
|
REPORTER_ASSERT(reporter, result.equals("path"));
|
|
|
|
|
|
|
|
#if defined(SK_BUILD_FOR_WIN)
|
|
|
|
result.reset();
|
|
|
|
path.set("path\\winbasename");
|
|
|
|
sk_tools::get_basename(&result, path);
|
|
|
|
REPORTER_ASSERT(reporter, result.equals("winbasename"));
|
|
|
|
|
|
|
|
result.reset();
|
|
|
|
path.set("path\\windir\\");
|
|
|
|
sk_tools::get_basename(&result, path);
|
|
|
|
REPORTER_ASSERT(reporter, result.equals("windir"));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-12-12 21:11:12 +00:00
|
|
|
DEF_TEST(PictureUtils, reporter) {
|
2012-07-09 18:44:51 +00:00
|
|
|
test_filepath_creation(reporter);
|
|
|
|
test_get_basename(reporter);
|
|
|
|
}
|