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#include "chrome/browser/chromeos/login/mixin_based_browser_test.h"
6
7namespace chromeos {
8
9MixinBasedBrowserTest::MixinBasedBrowserTest() : setup_was_launched_(false) {
10}
11
12MixinBasedBrowserTest::~MixinBasedBrowserTest() {
13}
14
15void MixinBasedBrowserTest::SetUpCommandLine(base::CommandLine* command_line) {
16  setup_was_launched_ = true;
17  for (ScopedVector<Mixin>::iterator it = mixins_.begin(); it != mixins_.end();
18       ++it) {
19    (*it)->SetUpCommandLine(command_line);
20  }
21  InProcessBrowserTest::SetUpCommandLine(command_line);
22}
23
24void MixinBasedBrowserTest::SetUpInProcessBrowserTestFixture() {
25  setup_was_launched_ = true;
26  for (ScopedVector<Mixin>::iterator it = mixins_.begin(); it != mixins_.end();
27       ++it) {
28    (*it)->SetUpInProcessBrowserTestFixture();
29  }
30  InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
31}
32
33void MixinBasedBrowserTest::SetUpOnMainThread() {
34  setup_was_launched_ = true;
35  for (ScopedVector<Mixin>::iterator it = mixins_.begin(); it != mixins_.end();
36       ++it) {
37    (*it)->SetUpOnMainThread();
38  }
39  InProcessBrowserTest::SetUpOnMainThread();
40}
41
42void MixinBasedBrowserTest::TearDownOnMainThread() {
43  InProcessBrowserTest::TearDownOnMainThread();
44  for (ScopedVector<Mixin>::reverse_iterator it = mixins_.rbegin();
45       it != mixins_.rend();
46       ++it) {
47    (*it)->TearDownInProcessBrowserTestFixture();
48  }
49}
50void MixinBasedBrowserTest::TearDownInProcessBrowserTestFixture() {
51  InProcessBrowserTest::TearDownInProcessBrowserTestFixture();
52  for (ScopedVector<Mixin>::reverse_iterator it = mixins_.rbegin();
53       it != mixins_.rend();
54       ++it) {
55    (*it)->TearDownInProcessBrowserTestFixture();
56  }
57}
58
59void MixinBasedBrowserTest::AddMixin(MixinBasedBrowserTest::Mixin* mixin) {
60  CHECK(!setup_was_launched_)
61      << "You are trying to add a mixin after setting up has already started.";
62  mixins_.push_back(mixin);
63}
64
65}  // namespace chromeos
66