Index: chrome/browser/translate/translate_browser_test_utils.h |
diff --git a/chrome/browser/translate/translate_browser_test_utils.h b/chrome/browser/translate/translate_browser_test_utils.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..86904d64ea883e99e8dd899c0cbdf7f0c70331a8 |
--- /dev/null |
+++ b/chrome/browser/translate/translate_browser_test_utils.h |
@@ -0,0 +1,55 @@ |
+// Copyright 2014 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. |
+ |
+#ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_BROWSER_TEST_UTILS_H_ |
+#define CHROME_BROWSER_TRANSLATE_TRANSLATE_BROWSER_TEST_UTILS_H_ |
+ |
+#include "base/macros.h" |
+ |
+namespace test { |
+ |
+// A utility class that sets up CLD dynamic data when constructed, and cleans |
+// it up when destroyed. |
+class ScopedCLDDynamicDataHarness { |
+ public: |
+ // Invokes whatever dark magic is required in order to make the CLD data |
+ // available immediately to testing code. The implementation may vary |
+ // depending on the following defines, bypassing any external data access |
+ // requirements. In pseudocode, this looks like the following: |
+ // |
+ // CLD_VERSION=2 && defined(CLD2_DYNAMIC_MODE) && !defined(CLD2_IS_COMPONENT): |
Takashi Toyoshima
2014/05/19 14:32:24
I feel these comments are not useful for developer
Andrew Hayden (chromium.org)
2014/05/19 15:14:21
Done.
|
+ // Copy the CLD data file from test data into it's default location: |
+ // ${chrome::DIR_USER_DATA}/${chrome::kCLDDataFilename} |
+ // |
+ // CLD_VERSION=2 && defined(CLD2_DYNAMIC_MODE) && defined(CLD2_IS_COMPONENT): |
+ // Copy the CLD CRX contents from test data into a realistic location: |
+ // ${chrome::DIR_USER_DATA}/${chrome::DIR_COMPONENT_CLD2}/${VERSION} |
+ // Call CldComponentInstallerTraits::SetLatestCldDataFile(...) |
+ // |
+ // In all other cases, the code does nothing because the CLD data is already |
+ // statically linked into the executable. |
+ // |
+ // The data for this class lives under: |
+ // src/chrome/test/data/cld2_component |
+ ScopedCLDDynamicDataHarness(); |
+ |
+ // Reverses the work done by the constructor: any files and/or directories |
+ // that would be created by the constructor are immediately and irrevocably |
+ // deleted. |
+ // |
+ // If dynamic data is not currently available for any reason, this method has |
+ // no net effect on the runtime. |
+ ~ScopedCLDDynamicDataHarness(); |
+ |
+ private: |
Takashi Toyoshima
2014/05/19 14:32:24
These three methods can be static, or functions in
Andrew Hayden (chromium.org)
2014/05/19 15:14:21
Done.
|
+ void MakeDynamicCLDDataAvailableForTest(); |
+ void MakeDynamicCLDDataUnavailableForTest(); |
+ void ClearStandaloneFileState(); |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ScopedCLDDynamicDataHarness); |
+}; |
+ |
+} // namespace test |
+ |
+#endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_BROWSER_TEST_UTILS_H_ |