summaryrefslogtreecommitdiffstats
path: root/content/test/test_content_client_initializer.cc
blob: 26cd3aaad5479da834ccf96a98d03859d47ddebc (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
// 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 "content/test/test_content_client_initializer.h"

#include "content/browser/mock_content_browser_client.h"
#include "content/browser/notification_service_impl.h"
#include "content/public/common/content_client.h"
#include "content/test/test_content_client.h"

namespace content {

TestContentClientInitializer::TestContentClientInitializer() {
  notification_service_.reset(new NotificationServiceImpl());

  DCHECK(!content::GetContentClient());
  content_client_.reset(new TestContentClient);
  content::SetContentClient(content_client_.get());

  content_browser_client_.reset(new content::MockContentBrowserClient());
  content_client_->set_browser(content_browser_client_.get());
}

TestContentClientInitializer::~TestContentClientInitializer() {
  notification_service_.reset();

  DCHECK_EQ(content_client_.get(), content::GetContentClient());
  content::SetContentClient(NULL);
  content_client_.reset();

  content_browser_client_.reset();
}

}  // namespace content