Add ICU message format support
[chromium-blink-merge.git] / ui / views / controls / native / native_view_host_test_base.cc
blobab40692550e81e2e2325329c56b30d9bde603170
1 // Copyright 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.
5 #include "ui/views/controls/native/native_view_host_test_base.h"
7 #include "ui/views/controls/native/native_view_host.h"
8 #include "ui/views/widget/widget.h"
10 namespace views {
11 namespace test {
13 // Testing wrapper of the NativeViewHost.
14 class NativeViewHostTestBase::NativeViewHostTesting : public NativeViewHost {
15 public:
16 explicit NativeViewHostTesting(NativeViewHostTestBase* owner)
17 : owner_(owner) {}
18 ~NativeViewHostTesting() override { owner_->host_destroyed_count_++; }
20 private:
21 NativeViewHostTestBase* owner_;
23 DISALLOW_COPY_AND_ASSIGN(NativeViewHostTesting);
26 NativeViewHostTestBase::NativeViewHostTestBase() : host_destroyed_count_(0) {
29 NativeViewHostTestBase::~NativeViewHostTestBase() {
32 void NativeViewHostTestBase::TearDown() {
33 DestroyTopLevel();
34 ViewsTestBase::TearDown();
37 void NativeViewHostTestBase::CreateTopLevel() {
38 toplevel_.reset(new Widget);
39 Widget::InitParams toplevel_params =
40 CreateParams(Widget::InitParams::TYPE_WINDOW);
41 toplevel_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
42 toplevel_->Init(toplevel_params);
45 void NativeViewHostTestBase::CreateTestingHost() {
46 host_.reset(new NativeViewHostTesting(this));
49 Widget* NativeViewHostTestBase::CreateChildForHost(
50 gfx::NativeView native_parent_view,
51 View* parent_view,
52 View* contents_view,
53 NativeViewHost* host) {
54 Widget* child = new Widget;
55 Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL);
56 child_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
57 child_params.parent = native_parent_view;
58 child->Init(child_params);
59 child->SetContentsView(contents_view);
61 // Owned by |parent_view|.
62 parent_view->AddChildView(host);
63 host->Attach(child->GetNativeView());
65 return child;
68 void NativeViewHostTestBase::DestroyTopLevel() {
69 toplevel_.reset();
72 void NativeViewHostTestBase::DestroyHost() {
73 host_.reset();
76 NativeViewHost* NativeViewHostTestBase::ReleaseHost() {
77 return host_.release();
80 NativeViewHostWrapper* NativeViewHostTestBase::GetNativeWrapper() {
81 return host_->native_wrapper_.get();
84 } // namespace test
85 } // namespace views