| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/translate/cld_data_harness.h" | |
| 6 | |
| 7 #include "base/lazy_instance.h" | |
| 8 #include "base/macros.h" | |
| 9 #include "base/path_service.h" | |
| 10 #include "chrome/browser/translate/component_cld_data_harness.h" | |
| 11 #include "chrome/browser/translate/standalone_cld_data_harness.h" | |
| 12 #include "chrome/common/chrome_paths.h" | |
| 13 #include "components/translate/content/common/cld_data_source.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | |
| 15 | |
| 16 namespace { | |
| 17 // This constant yields the version of the CRX that has been extracted into | |
| 18 // the test data directory, and must be kept in sync with what is there. | |
| 19 // A reciprocal comment has been placed in | |
| 20 // chrome/test/data/cld2_component/README.chromium; don't update one without | |
| 21 // updating the other. | |
| 22 const base::FilePath::CharType kCrxVersion[] = FILE_PATH_LITERAL("160"); | |
| 23 | |
| 24 class StaticCldDataHarness : public test::CldDataHarness { | |
| 25 public: | |
| 26 StaticCldDataHarness() {} | |
| 27 ~StaticCldDataHarness() override {}; | |
| 28 void Init() override { | |
| 29 translate::CldDataSource::Set( | |
| 30 translate::CldDataSource::GetStaticDataSource()); | |
| 31 } | |
| 32 private: | |
| 33 DISALLOW_COPY_AND_ASSIGN(StaticCldDataHarness); | |
| 34 }; | |
| 35 | |
| 36 } // namespace | |
| 37 | |
| 38 namespace test { | |
| 39 | |
| 40 const base::FilePath::CharType* CldDataHarness::GetTestDataSourceCrxVersion() { | |
| 41 return kCrxVersion; | |
| 42 } | |
| 43 | |
| 44 void CldDataHarness::GetTestDataSourceDirectory(base::FilePath* out_path) { | |
| 45 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, out_path)); | |
| 46 *out_path = | |
| 47 out_path->Append(FILE_PATH_LITERAL("cld2_component")).Append(kCrxVersion); | |
| 48 } | |
| 49 | |
| 50 // static | |
| 51 std::unique_ptr<CldDataHarness> CldDataHarness::CreateStaticDataHarness() { | |
| 52 return std::unique_ptr<CldDataHarness>(new StaticCldDataHarness()); | |
| 53 } | |
| 54 | |
| 55 // static | |
| 56 std::unique_ptr<CldDataHarness> CldDataHarness::CreateStandaloneDataHarness() { | |
| 57 return std::unique_ptr<CldDataHarness>(new StandaloneCldDataHarness()); | |
| 58 } | |
| 59 | |
| 60 // static | |
| 61 std::unique_ptr<CldDataHarness> CldDataHarness::CreateComponentDataHarness() { | |
| 62 return std::unique_ptr<CldDataHarness>(new ComponentCldDataHarness()); | |
| 63 } | |
| 64 | |
| 65 } // namespace test | |
| OLD | NEW |