summaryrefslogtreecommitdiffstats
path: root/courgette/base_test_unittest.cc
blob: 9a62868d9493af34c9aa66ecb0c4205cd56ecdf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "courgette/base_test_unittest.h"

#include "base/file_util.h"
#include "base/path_service.h"

void BaseTest::SetUp() {
  ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_dir_));
  test_dir_ = test_dir_.AppendASCII("courgette");
  test_dir_ = test_dir_.AppendASCII("testdata");
}

void BaseTest::TearDown() {
}

//  Reads a test file into a string.
std::string BaseTest::FileContents(const char* file_name) const {
  base::FilePath file_path = test_dir_;
  file_path = file_path.AppendASCII(file_name);
  std::string file_bytes;

  EXPECT_TRUE(base::ReadFileToString(file_path, &file_bytes));

  return file_bytes;
}

std::string BaseTest::FilesContents(std::list<std::string> file_names) const {
  std::string result;

  std::list<std::string>::iterator file_name = file_names.begin();

  while (file_name != file_names.end()) {
    result += FileContents(file_name->c_str());
    file_name++;
  }

  return result;
}