Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(865)

Unified Diff: ui/views/view_unittest.cc

Issue 191723003: Nukes USE_AURA ifdefs from views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/view_unittest.cc
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index b1d94ea526f3dee0a692898cadf35cf6aae991ea..3aecca9afc454979d79fd23515bd2b2a91e2d032 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -9,6 +9,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "grit/ui_strings.h"
+#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/l10n/l10n_util.h"
@@ -17,6 +18,7 @@
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/test/draw_waiter_for_test.h"
#include "ui/events/event.h"
+#include "ui/events/gestures/gesture_recognizer.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/path.h"
@@ -37,10 +39,6 @@
#if defined(OS_WIN)
#include "ui/views/test/test_views_delegate.h"
#endif
-#if defined(USE_AURA)
-#include "ui/aura/window_event_dispatcher.h"
-#include "ui/events/gestures/gesture_recognizer.h"
-#endif
using base::ASCIIToUTF16;
@@ -1585,218 +1583,6 @@ bool TestView::AcceleratorPressed(const ui::Accelerator& accelerator) {
return true;
}
-#if defined(OS_WIN) && !defined(USE_AURA)
msw 2014/03/08 01:04:50 nit: these were added in http://crrev.com/99278, p
sky 2014/03/08 01:30:28 Not sure. I'll leave them for now.
-TEST_F(ViewTest, ActivateAccelerator) {
- // Register a keyboard accelerator before the view is added to a window.
- ui::Accelerator return_accelerator(ui::VKEY_RETURN, ui::EF_NONE);
- TestView* view = new TestView();
- view->Reset();
- view->AddAccelerator(return_accelerator);
- EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0);
-
- // Create a window and add the view as its child.
- scoped_ptr<Widget> widget(new Widget);
- Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
- params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.bounds = gfx::Rect(0, 0, 100, 100);
- widget->Init(params);
- View* root = widget->GetRootView();
- root->AddChildView(view);
- widget->Show();
-
- // Get the focus manager.
- FocusManager* focus_manager = widget->GetFocusManager();
- ASSERT_TRUE(focus_manager);
-
- // Hit the return key and see if it takes effect.
- EXPECT_TRUE(focus_manager->ProcessAccelerator(return_accelerator));
- EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1);
-
- // Hit the escape key. Nothing should happen.
- ui::Accelerator escape_accelerator(ui::VKEY_ESCAPE, ui::EF_NONE);
- EXPECT_FALSE(focus_manager->ProcessAccelerator(escape_accelerator));
- EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1);
- EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 0);
-
- // Now register the escape key and hit it again.
- view->AddAccelerator(escape_accelerator);
- EXPECT_TRUE(focus_manager->ProcessAccelerator(escape_accelerator));
- EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1);
- EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 1);
-
- // Remove the return key accelerator.
- view->RemoveAccelerator(return_accelerator);
- EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator));
- EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1);
- EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 1);
-
- // Add it again. Hit the return key and the escape key.
- view->AddAccelerator(return_accelerator);
- EXPECT_TRUE(focus_manager->ProcessAccelerator(return_accelerator));
- EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 2);
- EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 1);
- EXPECT_TRUE(focus_manager->ProcessAccelerator(escape_accelerator));
- EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 2);
- EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 2);
-
- // Remove all the accelerators.
- view->ResetAccelerators();
- EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator));
- EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 2);
- EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 2);
- EXPECT_FALSE(focus_manager->ProcessAccelerator(escape_accelerator));
- EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 2);
- EXPECT_EQ(view->accelerator_count_map_[escape_accelerator], 2);
-
- widget->CloseNow();
-}
-#endif
-
-#if defined(OS_WIN) && !defined(USE_AURA)
-TEST_F(ViewTest, HiddenViewWithAccelerator) {
- ui::Accelerator return_accelerator(ui::VKEY_RETURN, ui::EF_NONE);
- TestView* view = new TestView();
- view->Reset();
- view->AddAccelerator(return_accelerator);
- EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0);
-
- scoped_ptr<Widget> widget(new Widget);
- Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
- params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.bounds = gfx::Rect(0, 0, 100, 100);
- widget->Init(params);
- View* root = widget->GetRootView();
- root->AddChildView(view);
- widget->Show();
-
- FocusManager* focus_manager = widget->GetFocusManager();
- ASSERT_TRUE(focus_manager);
-
- view->SetVisible(false);
- EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator));
-
- view->SetVisible(true);
- EXPECT_TRUE(focus_manager->ProcessAccelerator(return_accelerator));
-
- widget->CloseNow();
-}
-#endif
-
-#if defined(OS_WIN) && !defined(USE_AURA)
-TEST_F(ViewTest, ViewInHiddenWidgetWithAccelerator) {
- ui::Accelerator return_accelerator(ui::VKEY_RETURN, ui::EF_NONE);
- TestView* view = new TestView();
- view->Reset();
- view->AddAccelerator(return_accelerator);
- EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0);
-
- scoped_ptr<Widget> widget(new Widget);
- Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
- params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.bounds = gfx::Rect(0, 0, 100, 100);
- widget->Init(params);
- View* root = widget->GetRootView();
- root->AddChildView(view);
-
- FocusManager* focus_manager = widget->GetFocusManager();
- ASSERT_TRUE(focus_manager);
-
- EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator));
- EXPECT_EQ(0, view->accelerator_count_map_[return_accelerator]);
-
- widget->Show();
- EXPECT_TRUE(focus_manager->ProcessAccelerator(return_accelerator));
- EXPECT_EQ(1, view->accelerator_count_map_[return_accelerator]);
-
- widget->Hide();
- EXPECT_FALSE(focus_manager->ProcessAccelerator(return_accelerator));
- EXPECT_EQ(1, view->accelerator_count_map_[return_accelerator]);
-
- widget->CloseNow();
-}
-#endif
-
-#if defined(OS_WIN) && !defined(USE_AURA)
-////////////////////////////////////////////////////////////////////////////////
-// Mouse-wheel message rerouting
-////////////////////////////////////////////////////////////////////////////////
-class ScrollableTestView : public View {
- public:
- ScrollableTestView() { }
-
- virtual gfx::Size GetPreferredSize() {
- return gfx::Size(100, 10000);
- }
-
- virtual void Layout() {
- SizeToPreferredSize();
- }
-};
-
-class TestViewWithControls : public View {
- public:
- TestViewWithControls() {
- text_field_ = new Textfield();
- AddChildView(text_field_);
- }
-
- Textfield* text_field_;
-};
-
-class SimpleWidgetDelegate : public WidgetDelegate {
- public:
- explicit SimpleWidgetDelegate(View* contents) : contents_(contents) { }
-
- virtual void DeleteDelegate() { delete this; }
-
- virtual View* GetContentsView() { return contents_; }
-
- virtual Widget* GetWidget() { return contents_->GetWidget(); }
- virtual const Widget* GetWidget() const { return contents_->GetWidget(); }
-
- private:
- View* contents_;
-};
-
-// Tests that the mouse-wheel messages are correctly rerouted to the window
-// under the mouse.
-// TODO(jcampan): http://crbug.com/10572 Disabled as it fails on the Vista build
-// bot.
-// Note that this fails for a variety of reasons:
-// - focused view is apparently reset across window activations and never
-// properly restored
-// - this test depends on you not having any other window visible open under the
-// area that it opens the test windows. --beng
-TEST_F(ViewTest, DISABLED_RerouteMouseWheelTest) {
- TestViewWithControls* view_with_controls = new TestViewWithControls();
- Widget* window1 = Widget::CreateWindowWithBounds(
- new SimpleWidgetDelegate(view_with_controls),
- gfx::Rect(0, 0, 100, 100));
- window1->Show();
- ScrollView* scroll_view = new ScrollView();
- scroll_view->SetContents(new ScrollableTestView());
- Widget* window2 = Widget::CreateWindowWithBounds(
- new SimpleWidgetDelegate(scroll_view),
- gfx::Rect(200, 200, 100, 100));
- window2->Show();
- EXPECT_EQ(0, scroll_view->GetVisibleRect().y());
-
- // Make the window1 active, as this is what it would be in real-world.
- window1->Activate();
-
- // Let's send a mouse-wheel message to the different controls and check that
- // it is rerouted to the window under the mouse (effectively scrolling the
- // scroll-view).
-
- // First to the Window's HWND.
- ::SendMessage(view_with_controls->GetWidget()->GetNativeView(),
- WM_MOUSEWHEEL, MAKEWPARAM(0, -20), MAKELPARAM(250, 250));
- EXPECT_EQ(20, scroll_view->GetVisibleRect().y());
-
- window1->CloseNow();
- window2->CloseNow();
-}
-#endif
////////////////////////////////////////////////////////////////////////////////
// Native view hierachy
@@ -2960,8 +2746,6 @@ TEST_F(ViewTest, AddExistingChild) {
// Layers
////////////////////////////////////////////////////////////////////////////////
-#if defined(USE_AURA)
-
namespace {
// Test implementation of LayerAnimator.
@@ -3546,8 +3330,6 @@ TEST_F(ViewLayerTest, RecreateLayerZOrderWidgetParent) {
EXPECT_EQ(v1_old_layer, child_layers_post[2]);
}
-#endif // USE_AURA
-
TEST_F(ViewTest, FocusableAssertions) {
// View subclasses may change insets based on whether they are focusable,
// which effects the preferred size. To avoid preferred size changing around

Powered by Google App Engine
This is Rietveld 408576698