summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/tab_contents/test_tab_contents.cc
blob: a28e1176a7a1fe13c547a7e1c880d93c923e4df9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2012 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.

#include "chrome/browser/ui/tab_contents/test_tab_contents.h"

#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/web_contents.h"

using content::WebContents;

TabContentsTestHarness::TabContentsTestHarness()
    : ChromeRenderViewHostTestHarness() {
}

TabContentsTestHarness::~TabContentsTestHarness() {
}

WebContents* TabContentsTestHarness::web_contents() {
  return tab_contents_.get() ? tab_contents_->web_contents() : NULL;
}

TabContents* TabContentsTestHarness::tab_contents() {
  return tab_contents_.get();
}

void TabContentsTestHarness::SetContents(WebContents* contents) {
  tab_contents_.reset(contents ? new TabContents(contents) : NULL);
}

void TabContentsTestHarness::SetUp() {
  ChromeRenderViewHostTestHarness::SetUp();
  SetContents(CreateTestWebContents());
}

void TabContentsTestHarness::TearDown() {
  tab_contents_.reset();

  // Make sure that we flush any messages related to WebContents destruction
  // before we destroy the browser context.
  MessageLoop::current()->RunAllPending();

  // Release the browser context on the UI thread.
  message_loop_.DeleteSoon(FROM_HERE, browser_context_.release());
  message_loop_.RunAllPending();

  ChromeRenderViewHostTestHarness::TearDown();
}