Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Unified Diff: chrome/browser/autofill/data_driven_test.cc

Issue 12434004: Move remaining Autofill code to //components/autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix long lines Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autofill/data_driven_test.h ('k') | chrome/browser/autofill/email_field.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/data_driven_test.cc
diff --git a/chrome/browser/autofill/data_driven_test.cc b/chrome/browser/autofill/data_driven_test.cc
deleted file mode 100644
index 81111af3b8794910dd1d93517f6fab674eec3231..0000000000000000000000000000000000000000
--- a/chrome/browser/autofill/data_driven_test.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-// 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 "chrome/browser/autofill/data_driven_test.h"
-
-#include "base/file_util.h"
-#include "base/path_service.h"
-#include "base/string_util.h"
-#include "chrome/common/chrome_paths.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-// Reads |file| into |content|, and converts Windows line-endings to Unix ones.
-// Returns true on success.
-bool ReadFile(const base::FilePath& file, std::string* content) {
- if (!file_util::ReadFileToString(file, content))
- return false;
-
- ReplaceSubstringsAfterOffset(content, 0, "\r\n", "\n");
- return true;
-}
-
-// Write |content| to |file|. Returns true on success.
-bool WriteFile(const base::FilePath& file, const std::string& content) {
- int write_size = file_util::WriteFile(file, content.c_str(),
- content.length());
- return write_size == static_cast<int>(content.length());
-}
-
-} // namespace
-
-void DataDrivenTest::RunDataDrivenTest(
- const base::FilePath& input_directory,
- const base::FilePath& output_directory,
- const base::FilePath::StringType& file_name_pattern) {
- file_util::FileEnumerator input_files(input_directory,
- false,
- file_util::FileEnumerator::FILES,
- file_name_pattern);
-
- for (base::FilePath input_file = input_files.Next();
- !input_file.empty();
- input_file = input_files.Next()) {
- SCOPED_TRACE(input_file.BaseName().value());
-
- std::string input;
- ASSERT_TRUE(ReadFile(input_file, &input));
-
- std::string output;
- GenerateResults(input, &output);
-
- base::FilePath output_file = output_directory.Append(
- input_file.BaseName().StripTrailingSeparators().ReplaceExtension(
- FILE_PATH_LITERAL(".out")));
-
- std::string output_file_contents;
- if (ReadFile(output_file, &output_file_contents))
- EXPECT_EQ(output_file_contents, output);
- else
- ASSERT_TRUE(WriteFile(output_file, output));
- }
-}
-
-base::FilePath DataDrivenTest::GetInputDirectory(
- const base::FilePath::StringType& test_name) {
- base::FilePath test_data_dir_;
- PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_);
- test_data_dir_ = test_data_dir_.AppendASCII("autofill")
- .Append(test_name)
- .AppendASCII("input");
- return test_data_dir_;
-}
-
-base::FilePath DataDrivenTest::GetOutputDirectory(
- const base::FilePath::StringType& test_name) {
- base::FilePath test_data_dir_;
- PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_);
- test_data_dir_ = test_data_dir_.AppendASCII("autofill")
- .Append(test_name)
- .AppendASCII("output");
- return test_data_dir_;
-}
-
-DataDrivenTest::DataDrivenTest() {
-}
-
-DataDrivenTest::~DataDrivenTest() {
-}
« no previous file with comments | « chrome/browser/autofill/data_driven_test.h ('k') | chrome/browser/autofill/email_field.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698