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

Side by Side Diff: chrome/browser/chromeos/login/mixin_based_browser_test.h

Issue 574703002: Creating mixin-supporting InProcessBrowserTests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: edited .gypi so that it links correctly everywhere where LoginManagerTest appears Created 6 years, 3 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
OLDNEW
(Empty)
1 // Copyright (c) 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_CHROMEOS_LOGIN_MIXIN_BASED_BROWSER_TEST_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MIXIN_BASED_BROWSER_TEST_H_
7
8 #include "base/memory/scoped_vector.h"
9 #include "chrome/test/base/in_process_browser_test.h"
10
11 namespace chromeos {
12
13 class MixinBasedBrowserTest : public InProcessBrowserTest {
14 public:
15 // A class that can be used to add some features not related directly to the
16 // testing process in order not to make the test class too complicated and to
17 // set up them in a proper time (at the same time when the corresponding set
18 // ups for the main test are run).
19 //
20 // To used this you need to derive a class from from
21 // MixinBasedBrowserTest::Mixin, e.g. MixinYouWantToUse, and declare all
22 // the methods you'd like in this new class. You also can reload setups and
23 // teardowns if you need so. Test which wants to use some mixin should call
24 // AddMixin(mixin_) from its constructor, where mixin_ should be an instance
25 // of MixinYouWantToUse.
26 //
27 // All methods in Mixin are complete analogs of those in InProcessBrowserTest,
28 // so if some usecases are unclear, take a look at in_process_browser_test.h
29 class Mixin {
30 public:
31 Mixin() {}
32 virtual ~Mixin() {}
33
34 // Is called before creating the browser and running
35 // SetUpInProcessBrowserTestFixture.
36 // Should be used for setting up the command line.
37 virtual void SetUpCommandLine(base::CommandLine* command_line) {}
38
39 // Is called before creating the browser.
40 // Should be used to set up the environment for running the browser.
41 virtual void SetUpInProcessBrowserTestFixture() {}
42
43 // Is called after creating the browser and before executing test code.
44 // Should be used for setting up things related to the browser object.
45 virtual void SetUpOnMainThread() {}
46
47 // Is called after executing the test code and before the browser is torn
48 // down.
49 // Should be used to do the necessary cleanup on the working browser.
50 virtual void TearDownOnMainThread() {}
51
52 // Is called after the browser is torn down.
53 // Should be used to do the remaining cleanup.
54 virtual void TearDownInProcessBrowserTestFixture() {}
55 };
56
57 MixinBasedBrowserTest();
58 virtual ~MixinBasedBrowserTest();
59
60 // Override from InProcessBrowserTest.
61 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
62 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE;
63 virtual void SetUpOnMainThread() OVERRIDE;
64 virtual void TearDownOnMainThread() OVERRIDE;
65 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE;
66
67 protected:
68 // Adds |mixin| as an mixin for this test, passing ownership
69 // for it to MixinBasedBrowserTest.
70 // Should be called in constructor of the test (should be already completed
71 // before running set ups).
72 void AddMixin(Mixin* mixin);
73
74 private:
75 // Keeps all the mixins for this test,
76 ScopedVector<Mixin> mixins_;
77
78 // Is false initially, becomes true when any of SetUp* methods is called.
79 // Required to check that AddMixin is always called before setting up.
80 bool setup_was_launched_;
81 };
82
83 } // namespace chromeos
84
85 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MIXIN_BASED_BROWSER_TEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/login_manager_test.cc ('k') | chrome/browser/chromeos/login/mixin_based_browser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698