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 "base/macros.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "ui/views/test/views_test_base.h"
12 class NativeViewHostWrapper
;
17 // Base class for NativeViewHost tests on different platforms.
18 class NativeViewHostTestBase
: public ViewsTestBase
{
20 NativeViewHostTestBase();
21 ~NativeViewHostTestBase() override
;
24 void TearDown() override
;
26 // Create the |toplevel_| widget.
27 void CreateTopLevel();
29 // Create a testing |host_| that tracks destructor calls.
30 void CreateTestingHost();
32 // The number of times a host created by CreateHost() has been destroyed.
33 int host_destroyed_count() { return host_destroyed_count_
; }
34 void ResetHostDestroyedCount() { host_destroyed_count_
= 0; }
36 // Create a child widget whose native parent is |native_parent_view|, uses
37 // |contents_view|, and is attached to |host| which is added as a child to
38 // |parent_view|. This effectively borrows the native content view from a
39 // newly created child Widget, and attaches it to |host|.
40 Widget
* CreateChildForHost(gfx::NativeView native_parent_view
,
43 NativeViewHost
* host
);
45 Widget
* toplevel() { return toplevel_
.get(); }
46 void DestroyTopLevel();
48 NativeViewHost
* host() { return host_
.get(); }
50 NativeViewHost
* ReleaseHost();
52 NativeViewHostWrapper
* GetNativeWrapper();
55 class NativeViewHostTesting
;
57 scoped_ptr
<Widget
> toplevel_
;
58 scoped_ptr
<NativeViewHost
> host_
;
59 int host_destroyed_count_
;
61 DISALLOW_COPY_AND_ASSIGN(NativeViewHostTestBase
);