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

Unified Diff: chrome/browser/translate/translate_browser_test_utils.h

Issue 285293004: Allow browser tests to run with dynamic CLD data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cld_uma
Patch Set: Created 6 years, 7 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
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..7c91410b19adb4844a35eda6aa49bcbc3668a681
--- /dev/null
+++ b/chrome/browser/translate/translate_browser_test_utils.h
@@ -0,0 +1,59 @@
+// 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_
+
+namespace test {
+
+// A utility class that sets up CLD dynamic data when constructed, and cleans
+// it up when destroyed.
+class ScopedCLDDynamicDataHarness {
+
Sorin Jianu 2014/05/15 17:16:13 There are some extra white space lines in this cla
Andrew Hayden (chromium.org) 2014/05/16 17:53:20 I'll do a separate lint pass shortly.
+ 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):
+ // 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();
+
+ // Reverse the work done by the constructor: any files and/or directories
Sorin Jianu 2014/05/15 17:16:13 Reverses.
Andrew Hayden (chromium.org) 2014/05/16 17:53:20 Done.
+ // 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:
+
+ // Invoked by the constructor; declared so a friend declaration can be made
Sorin Jianu 2014/05/15 17:16:13 @47 AND @51, arguably comments not needed. Where
Andrew Hayden (chromium.org) 2014/05/16 17:53:20 Done. Sorry about the confusion.
+ // in the required places to give this class access to private data
+ void MakeDynamicCLDDataAvailableForTest();
+
+ // Invoked by the destructor; declared so a friend declaration can be made
+ // in the required places to give this class access to private data
+ void MakeDynamicCLDDataUnavailableForTest();
+
Sorin Jianu 2014/05/15 17:16:13 Do we need to have value semantics in this class?
Andrew Hayden (chromium.org) 2014/05/16 17:53:20 Done.
+};
+
+} // namespace test
+
+#endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_BROWSER_TEST_UTILS_H_

Powered by Google App Engine
This is Rietveld 408576698