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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/mixin_based_browser_test.h
diff --git a/chrome/browser/chromeos/login/mixin_based_browser_test.h b/chrome/browser/chromeos/login/mixin_based_browser_test.h
new file mode 100644
index 0000000000000000000000000000000000000000..af367f24739f3a3cb8e9140c39e9d216f0270be1
--- /dev/null
+++ b/chrome/browser/chromeos/login/mixin_based_browser_test.h
@@ -0,0 +1,85 @@
+// Copyright (c) 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_CHROMEOS_LOGIN_MIXIN_BASED_BROWSER_TEST_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_MIXIN_BASED_BROWSER_TEST_H_
+
+#include "base/memory/scoped_vector.h"
+#include "chrome/test/base/in_process_browser_test.h"
+
+namespace chromeos {
+
+class MixinBasedBrowserTest : public InProcessBrowserTest {
+ public:
+ // A class that can be used to add some features not related directly to the
+ // testing process in order not to make the test class too complicated and to
+ // set up them in a proper time (at the same time when the corresponding set
+ // ups for the main test are run).
+ //
+ // To used this you need to derive a class from from
+ // MixinBasedBrowserTest::Mixin, e.g. MixinYouWantToUse, and declare all
+ // the methods you'd like in this new class. You also can reload setups and
+ // teardowns if you need so. Test which wants to use some mixin should call
+ // AddMixin(mixin_) from its constructor, where mixin_ should be an instance
+ // of MixinYouWantToUse.
+ //
+ // All methods in Mixin are complete analogs of those in InProcessBrowserTest,
+ // so if some usecases are unclear, take a look at in_process_browser_test.h
+ class Mixin {
+ public:
+ Mixin() {}
+ virtual ~Mixin() {}
+
+ // Is called before creating the browser and running
+ // SetUpInProcessBrowserTestFixture.
+ // Should be used for setting up the command line.
+ virtual void SetUpCommandLine(base::CommandLine* command_line) {}
+
+ // Is called before creating the browser.
+ // Should be used to set up the environment for running the browser.
+ virtual void SetUpInProcessBrowserTestFixture() {}
+
+ // Is called after creating the browser and before executing test code.
+ // Should be used for setting up things related to the browser object.
+ virtual void SetUpOnMainThread() {}
+
+ // Is called after executing the test code and before the browser is torn
+ // down.
+ // Should be used to do the necessary cleanup on the working browser.
+ virtual void TearDownOnMainThread() {}
+
+ // Is called after the browser is torn down.
+ // Should be used to do the remaining cleanup.
+ virtual void TearDownInProcessBrowserTestFixture() {}
+ };
+
+ MixinBasedBrowserTest();
+ virtual ~MixinBasedBrowserTest();
+
+ // Override from InProcessBrowserTest.
+ virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
+ virtual void SetUpInProcessBrowserTestFixture() OVERRIDE;
+ virtual void SetUpOnMainThread() OVERRIDE;
+ virtual void TearDownOnMainThread() OVERRIDE;
+ virtual void TearDownInProcessBrowserTestFixture() OVERRIDE;
+
+ protected:
+ // Adds |mixin| as an mixin for this test, passing ownership
+ // for it to MixinBasedBrowserTest.
+ // Should be called in constructor of the test (should be already completed
+ // before running set ups).
+ void AddMixin(Mixin* mixin);
+
+ private:
+ // Keeps all the mixins for this test,
+ ScopedVector<Mixin> mixins_;
+
+ // Is false initially, becomes true when any of SetUp* methods is called.
+ // Required to check that AddMixin is always called before setting up.
+ bool setup_was_launched_;
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_MIXIN_BASED_BROWSER_TEST_H_
« 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