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

Side by Side Diff: chrome/browser/translate/translate_browser_test_utils.h

Issue 333603002: Modularize Compact Language Detector 2 (CLD2) data sources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge https://codereview.chromium.org/326383005 Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_BROWSER_TEST_UTILS_H_
6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_BROWSER_TEST_UTILS_H_
7
8 #include "base/macros.h"
9
10 namespace test {
11
12 // A utility class that sets up CLD dynamic data upon calling Init() and cleans
13 // it up when destroyed.
14 // Test data lives under: src/chrome/test/data/cld2_component
15 //
16 // This class is intended to be instantiated within IN_PROC_BROWSER_TEST_F
17 // test fixtures; it uses ASSERT macros for correctness, so that tests will
18 // fail gracefully in error conditions. Sample use:
19 //
20 // IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) {
21 // test::ScopedCLDDynamicDataHarness dynamic_data_scope;
22 // ASSERT_NO_FATAL_FAILURE(dynamic_data_scope.Init());
23 // // ... your code that depends on language detection goes here
24 // }
25 //
26 // If you have a lot of tests that need language translation features, you can
27 // add an instance of the ScopedCLDDynamicDataHarness to your test class'
28 // private member variables and add the call to Init() into SetUpOnMainThread.
29 // Sample use:
30 //
31 // class MyTestClass : public InProcessBrowserTest {
32 // public:
33 // virtual void SetUpOnMainThread() OVERRIDE {
34 // dynamic_data_scope.Init();
35 // InProcessBrowserTest::SetUpOnMainThread();
36 // }
37 // private:
38 // test::ScopedCLDDynamicDataHarness dynamic_data_scope;
39 // };
40 //
41 class ScopedCLDDynamicDataHarness {
42 public:
43 // Constructs the object, but does nothing. Call Init() to prepare the
44 // harness, and enclose that call in ASSERT_NO_FATAL_FAILURE(...).
45 ScopedCLDDynamicDataHarness();
46
47 // Reverses the work done by the constructor: any files and/or directories
48 // that would be created by the constructor are immediately and irrevocably
49 // deleted.
50 // If dynamic data is not currently available for any reason, this method has
51 // no net effect on the runtime.
52 ~ScopedCLDDynamicDataHarness();
53
54 // Call this method, wrapping it in ASSERT_NO_FATAL_FAILURE, to initialize
55 // the harness and trigger test failure of initialization fails.
56 void Init();
57
58 private:
59 void ClearStandaloneDataFileState();
60
61 DISALLOW_COPY_AND_ASSIGN(ScopedCLDDynamicDataHarness);
62 };
63
64 } // namespace test
65
66 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_BROWSER_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « chrome/browser/translate/static_cld_data_harness.cc ('k') | chrome/browser/translate/translate_browser_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698