Home | History | Annotate | Download | only in login
      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 
      7 namespace chromeos {
      8 
      9 MixinBasedBrowserTest::MixinBasedBrowserTest() : setup_was_launched_(false) {
     10 }
     11 
     12 MixinBasedBrowserTest::~MixinBasedBrowserTest() {
     13 }
     14 
     15 void 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 
     24 void 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 
     33 void 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 
     42 void 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 }
     50 void 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 
     59 void 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