summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-14 14:08:11 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-14 14:08:11 +0000
commit93e828f68d9fa073d4acbcf9b156688f3a800585 (patch)
treec9118514d5a308d50f83a6291eed412b5c75be72 /ash
parentfbd06ad494c125a3834483a1e6987d3e2ca64618 (diff)
downloadchromium_src-93e828f68d9fa073d4acbcf9b156688f3a800585.zip
chromium_src-93e828f68d9fa073d4acbcf9b156688f3a800585.tar.gz
chromium_src-93e828f68d9fa073d4acbcf9b156688f3a800585.tar.bz2
Reduce creation of ViewsDelegate
By consolidating override of OnBeforeWidgetInit that finds shell many of the places that were setting a viewsdelegate no longer need to. Also, made AshTestHelper install a ViewsDelegate so that tests don't have. Because of removed an include of views_delegate from ash_test_helper I had to update some includes. BUG=none TEST=none R=ben@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=270290 Review URL: https://codereview.chromium.org/280863002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270399 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/drag_drop/drag_drop_controller_unittest.cc3
-rw-r--r--ash/first_run/first_run_helper_unittest.cc1
-rw-r--r--ash/screensaver/screensaver_view_unittest.cc2
-rw-r--r--ash/test/ash_test_base.cc8
-rw-r--r--ash/test/ash_test_base.h13
-rw-r--r--ash/test/ash_test_helper.cc6
-rw-r--r--ash/test/ash_test_helper.h6
-rw-r--r--ash/test/ash_test_views_delegate.cc38
-rw-r--r--ash/test/ash_test_views_delegate.h37
-rw-r--r--ash/touch/touch_observer_hud_unittest.cc1
-rw-r--r--ash/wm/gestures/overview_gesture_handler_unittest.cc1
-rw-r--r--ash/wm/mru_window_tracker_unittest.cc1
-rw-r--r--ash/wm/system_gesture_event_filter_unittest.cc2
14 files changed, 93 insertions, 28 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index a69869d..d23db52 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -804,6 +804,8 @@
'test/ash_test_base.h',
'test/ash_test_helper.cc',
'test/ash_test_helper.h',
+ 'test/ash_test_views_delegate.cc',
+ 'test/ash_test_views_delegate.h',
'test/cursor_manager_test_api.cc',
'test/cursor_manager_test_api.h',
'test/display_manager_test_api.cc',
diff --git a/ash/drag_drop/drag_drop_controller_unittest.cc b/ash/drag_drop/drag_drop_controller_unittest.cc
index 9ef0b9b..7e84ed4 100644
--- a/ash/drag_drop/drag_drop_controller_unittest.cc
+++ b/ash/drag_drop/drag_drop_controller_unittest.cc
@@ -26,7 +26,6 @@
#include "ui/events/gestures/gesture_types.h"
#include "ui/gfx/animation/linear_animation.h"
#include "ui/gfx/image/image_skia_rep.h"
-#include "ui/views/test/test_views_delegate.h"
#include "ui/views/view.h"
#include "ui/views/views_delegate.h"
#include "ui/views/widget/native_widget_aura.h"
@@ -299,7 +298,6 @@ class DragDropControllerTest : public AshTestBase {
drag_drop_controller_->set_should_block_during_drag_drop(false);
aura::client::SetDragDropClient(Shell::GetPrimaryRootWindow(),
drag_drop_controller_.get());
- views_delegate_.reset(new views::TestViewsDelegate);
}
virtual void TearDown() OVERRIDE {
@@ -344,7 +342,6 @@ class DragDropControllerTest : public AshTestBase {
protected:
scoped_ptr<TestDragDropController> drag_drop_controller_;
- scoped_ptr<views::TestViewsDelegate> views_delegate_;
private:
DISALLOW_COPY_AND_ASSIGN(DragDropControllerTest);
diff --git a/ash/first_run/first_run_helper_unittest.cc b/ash/first_run/first_run_helper_unittest.cc
index a86c064..15e42bf 100644
--- a/ash/first_run/first_run_helper_unittest.cc
+++ b/ash/first_run/first_run_helper_unittest.cc
@@ -10,6 +10,7 @@
#include "ash/test/ash_test_base.h"
#include "ui/aura/test/event_generator.h"
#include "ui/events/event_handler.h"
+#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_delegate.h"
namespace ash {
diff --git a/ash/screensaver/screensaver_view_unittest.cc b/ash/screensaver/screensaver_view_unittest.cc
index 19be19e..2809025 100644
--- a/ash/screensaver/screensaver_view_unittest.cc
+++ b/ash/screensaver/screensaver_view_unittest.cc
@@ -18,7 +18,6 @@ class ScreensaverViewTest : public ash::test::AshTestBase {
public:
ScreensaverViewTest() {
url_ = GURL("http://www.google.com");
- views_delegate_.reset(new AshTestViewsDelegate());
webview_test_helper_.reset(new views::WebViewTestHelper());
}
@@ -44,7 +43,6 @@ class ScreensaverViewTest : public ash::test::AshTestBase {
GURL url_;
private:
- scoped_ptr<AshTestViewsDelegate> views_delegate_;
scoped_ptr<views::WebViewTestHelper> webview_test_helper_;
DISALLOW_COPY_AND_ASSIGN(ScreensaverViewTest);
diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc
index 61fa218..cfd3142 100644
--- a/ash/test/ash_test_base.cc
+++ b/ash/test/ash_test_base.cc
@@ -19,7 +19,6 @@
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/window_positioner.h"
#include "base/command_line.h"
-#include "content/public/test/web_contents_tester.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/client/window_tree_client.h"
@@ -81,13 +80,6 @@ class AshEventGeneratorDelegate : public aura::test::EventGeneratorDelegate {
} // namespace
-content::WebContents* AshTestViewsDelegate::CreateWebContents(
- content::BrowserContext* browser_context,
- content::SiteInstance* site_instance) {
- return content::WebContentsTester::CreateTestWebContents(browser_context,
- site_instance);
-}
-
/////////////////////////////////////////////////////////////////////////////
AshTestBase::AshTestBase()
diff --git a/ash/test/ash_test_base.h b/ash/test/ash_test_base.h
index 4ac828e..6ef1591 100644
--- a/ash/test/ash_test_base.h
+++ b/ash/test/ash_test_base.h
@@ -13,13 +13,16 @@
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkColor.h"
-#include "ui/views/test/test_views_delegate.h"
#include "ui/wm/public/window_types.h"
#if defined(OS_WIN)
#include "ui/base/win/scoped_ole_initializer.h"
#endif
+namespace gfx {
+class Rect;
+}
+
namespace aura {
class RootWindow;
class Window;
@@ -42,14 +45,6 @@ class TestSystemTrayDelegate;
class TestMetroViewerProcessHost;
#endif
-class AshTestViewsDelegate : public views::TestViewsDelegate {
- public:
- // Overriden from TestViewsDelegate.
- virtual content::WebContents* CreateWebContents(
- content::BrowserContext* browser_context,
- content::SiteInstance* site_instance) OVERRIDE;
-};
-
class AshTestBase : public testing::Test {
public:
AshTestBase();
diff --git a/ash/test/ash_test_helper.cc b/ash/test/ash_test_helper.cc
index 9cf3488..a59019b 100644
--- a/ash/test/ash_test_helper.cc
+++ b/ash/test/ash_test_helper.cc
@@ -7,6 +7,7 @@
#include "ash/accelerators/accelerator_controller.h"
#include "ash/ash_switches.h"
#include "ash/shell.h"
+#include "ash/test/ash_test_views_delegate.h"
#include "ash/test/display_manager_test_api.h"
#include "ash/test/shell_test_api.h"
#include "ash/test/test_screenshot_delegate.h"
@@ -22,7 +23,6 @@
#include "ui/compositor/test/context_factories_for_test.h"
#include "ui/message_center/message_center.h"
#include "ui/wm/core/capture_controller.h"
-#include "ui/wm/core/wm_state.h"
#if defined(OS_CHROMEOS)
#include "chromeos/audio/cras_audio_handler.h"
@@ -56,7 +56,7 @@ AshTestHelper::~AshTestHelper() {
}
void AshTestHelper::SetUp(bool start_session) {
- wm_state_.reset(new wm::WMState);
+ views_delegate_.reset(new AshTestViewsDelegate);
// Disable animations during tests.
zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode(
@@ -133,7 +133,7 @@ void AshTestHelper::TearDown() {
CHECK(!wm::ScopedCaptureClient::IsActive());
- wm_state_.reset();
+ views_delegate_.reset();
}
void AshTestHelper::RunAllPendingInMessageLoop() {
diff --git a/ash/test/ash_test_helper.h b/ash/test/ash_test_helper.h
index 6fb266f..b42cc72 100644
--- a/ash/test/ash_test_helper.h
+++ b/ash/test/ash_test_helper.h
@@ -20,8 +20,8 @@ namespace ui {
class ScopedAnimationDurationScaleMode;
} // namespace ui
-namespace wm {
-class WMState;
+namespace views {
+class ViewsDelegate;
}
namespace ash {
@@ -77,7 +77,7 @@ class AshTestHelper {
// Owned by ash::AcceleratorController
TestScreenshotDelegate* test_screenshot_delegate_;
- scoped_ptr<wm::WMState> wm_state_;
+ scoped_ptr<views::ViewsDelegate> views_delegate_;
// Check if DBus Thread Manager was initialized here.
bool dbus_thread_manager_initialized_;
diff --git a/ash/test/ash_test_views_delegate.cc b/ash/test/ash_test_views_delegate.cc
new file mode 100644
index 0000000..c47bdba
--- /dev/null
+++ b/ash/test/ash_test_views_delegate.cc
@@ -0,0 +1,38 @@
+// Copyright 2014 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 "ash/test/ash_test_views_delegate.h"
+
+#include "ash/shell.h"
+#include "content/public/test/web_contents_tester.h"
+
+namespace ash {
+namespace test {
+
+AshTestViewsDelegate::AshTestViewsDelegate() {
+}
+
+AshTestViewsDelegate::~AshTestViewsDelegate() {
+}
+
+content::WebContents* AshTestViewsDelegate::CreateWebContents(
+ content::BrowserContext* browser_context,
+ content::SiteInstance* site_instance) {
+ return content::WebContentsTester::CreateTestWebContents(browser_context,
+ site_instance);
+}
+
+void AshTestViewsDelegate::OnBeforeWidgetInit(
+ views::Widget::InitParams* params,
+ views::internal::NativeWidgetDelegate* delegate) {
+ TestViewsDelegate::OnBeforeWidgetInit(params, delegate);
+
+ if (!params->parent && !params->context && ash::Shell::HasInstance()) {
+ // If the window has neither a parent nor a context add to the root.
+ params->parent = ash::Shell::GetInstance()->GetPrimaryRootWindow();
+ }
+}
+
+} // namespace test
+} // namespace ash
diff --git a/ash/test/ash_test_views_delegate.h b/ash/test/ash_test_views_delegate.h
new file mode 100644
index 0000000..6fd8bd4
--- /dev/null
+++ b/ash/test/ash_test_views_delegate.h
@@ -0,0 +1,37 @@
+// Copyright 2014 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.
+
+#ifndef ASH_TEST_ASH_TEST_VIEWS_DELEGATE_H_
+#define ASH_TEST_ASH_TEST_VIEWS_DELEGATE_H_
+
+#include "ui/views/test/test_views_delegate.h"
+
+namespace ash {
+namespace test {
+
+// Ash specific ViewsDelegate. In addition to creating a TestWebContents this
+// parents widget with no parent/context to the shell. This is created by
+// default AshTestHelper.
+class AshTestViewsDelegate : public views::TestViewsDelegate {
+ public:
+ AshTestViewsDelegate();
+ virtual ~AshTestViewsDelegate();
+
+ // Overriden from TestViewsDelegate.
+ virtual content::WebContents* CreateWebContents(
+ content::BrowserContext* browser_context,
+ content::SiteInstance* site_instance) OVERRIDE;
+ virtual void OnBeforeWidgetInit(
+ views::Widget::InitParams* params,
+ views::internal::NativeWidgetDelegate* delegate) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AshTestViewsDelegate);
+};
+
+} // namespace test
+} // namespace ash
+
+#endif // ASH_TEST_ASH_TEST_VIEWS_DELEGATE_H_
+
diff --git a/ash/touch/touch_observer_hud_unittest.cc b/ash/touch/touch_observer_hud_unittest.cc
index e0e133f..d5c7e2a 100644
--- a/ash/touch/touch_observer_hud_unittest.cc
+++ b/ash/touch/touch_observer_hud_unittest.cc
@@ -17,6 +17,7 @@
#include "base/format_macros.h"
#include "base/strings/stringprintf.h"
#include "ui/aura/window.h"
+#include "ui/views/widget/widget.h"
namespace ash {
diff --git a/ash/wm/gestures/overview_gesture_handler_unittest.cc b/ash/wm/gestures/overview_gesture_handler_unittest.cc
index 01eb012..0c0ee28 100644
--- a/ash/wm/gestures/overview_gesture_handler_unittest.cc
+++ b/ash/wm/gestures/overview_gesture_handler_unittest.cc
@@ -11,6 +11,7 @@
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
+#include "ui/views/widget/widget.h"
namespace ash {
diff --git a/ash/wm/mru_window_tracker_unittest.cc b/ash/wm/mru_window_tracker_unittest.cc
index 8c507e1..2c08a5d 100644
--- a/ash/wm/mru_window_tracker_unittest.cc
+++ b/ash/wm/mru_window_tracker_unittest.cc
@@ -11,6 +11,7 @@
#include "base/compiler_specific.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/window.h"
+#include "ui/views/widget/widget.h"
namespace ash {
diff --git a/ash/wm/system_gesture_event_filter_unittest.cc b/ash/wm/system_gesture_event_filter_unittest.cc
index 47f46df..fe1da3d 100644
--- a/ash/wm/system_gesture_event_filter_unittest.cc
+++ b/ash/wm/system_gesture_event_filter_unittest.cc
@@ -35,7 +35,9 @@
#include "ui/events/test/test_event_handler.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/size.h"
+#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
+#include "ui/views/window/non_client_view.h"
namespace ash {
namespace test {