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
;
23 // Create the |toplevel_| widget.
24 void CreateTopLevel();
26 // Create a testing |host_| that tracks destructor calls.
27 void CreateTestingHost();
29 // The number of times a host created by CreateHost() has been destroyed.
30 int host_destroyed_count() { return host_destroyed_count_
; }
31 void ResetHostDestroyedCount() { host_destroyed_count_
= 0; }
33 // Create a child widget whose native parent is |native_parent_view|, uses
34 // |contents_view|, and is attached to |host| which is added as a child to
35 // |parent_view|. This effectively borrows the native content view from a
36 // newly created child Widget, and attaches it to |host|.
37 Widget
* CreateChildForHost(gfx::NativeView native_parent_view
,
40 NativeViewHost
* host
);
42 Widget
* toplevel() { return toplevel_
.get(); }
43 void DestroyTopLevel();
45 NativeViewHost
* host() { return host_
.get(); }
47 NativeViewHost
* ReleaseHost();
49 NativeViewHostWrapper
* GetNativeWrapper();
52 class NativeViewHostTesting
;
54 scoped_ptr
<Widget
> toplevel_
;
55 scoped_ptr
<NativeViewHost
> host_
;
56 int host_destroyed_count_
;
58 DISALLOW_COPY_AND_ASSIGN(NativeViewHostTestBase
);