| Index: ui/views/widget/widget_interactive_uitest.cc
|
| diff --git a/ui/views/widget/widget_interactive_uitest.cc b/ui/views/widget/widget_interactive_uitest.cc
|
| index ae547ad61d74c98f78ebac29920d15f72022df0e..59f966ba05fadfe495ea54279edec654cdf1ec2f 100644
|
| --- a/ui/views/widget/widget_interactive_uitest.cc
|
| +++ b/ui/views/widget/widget_interactive_uitest.cc
|
| @@ -4,19 +4,25 @@
|
|
|
| #include "base/basictypes.h"
|
| #include "base/bind.h"
|
| +#include "base/command_line.h"
|
| #include "base/path_service.h"
|
| #include "base/run_loop.h"
|
| #include "base/strings/stringprintf.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| #include "ui/aura/client/focus_client.h"
|
| #include "ui/aura/env.h"
|
| +#include "ui/aura/test/event_generator.h"
|
| #include "ui/aura/window.h"
|
| #include "ui/aura/window_tree_host.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| #include "ui/base/ui_base_paths.h"
|
| +#include "ui/base/ui_base_switches.h"
|
| #include "ui/events/event_processor.h"
|
| #include "ui/gfx/native_widget_types.h"
|
| #include "ui/gl/gl_surface.h"
|
| +#include "ui/views/controls/textfield/textfield.h"
|
| #include "ui/views/test/widget_test.h"
|
| +#include "ui/views/touchui/touch_selection_controller_impl.h"
|
| #include "ui/views/widget/widget.h"
|
| #include "ui/views/window/dialog_delegate.h"
|
| #include "ui/wm/public/activation_client.h"
|
| @@ -162,6 +168,28 @@ class WidgetTestInteractive : public WidgetTest {
|
| ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file);
|
| WidgetTest::SetUp();
|
| }
|
| +
|
| + protected:
|
| + void ShowTouchSelectionQuickMenuImmediately(Textfield* textfield) {
|
| + DCHECK(textfield);
|
| + DCHECK(textfield->touch_selection_controller_);
|
| + TouchSelectionControllerImpl* controller =
|
| + static_cast<TouchSelectionControllerImpl*>(
|
| + textfield->touch_selection_controller_.get());
|
| + if (controller->context_menu_timer_.IsRunning()) {
|
| + controller->context_menu_timer_.Stop();
|
| + controller->ContextMenuTimerFired();
|
| + }
|
| + }
|
| +
|
| + bool TouchSelectionQuickMenuIsVisible(Textfield* textfield) {
|
| + DCHECK(textfield);
|
| + DCHECK(textfield->touch_selection_controller_);
|
| + TouchSelectionControllerImpl* controller =
|
| + static_cast<TouchSelectionControllerImpl*>(
|
| + textfield->touch_selection_controller_.get());
|
| + return controller->context_menu_ && controller->context_menu_->visible();
|
| + }
|
| };
|
|
|
| #if defined(OS_WIN)
|
| @@ -702,6 +730,56 @@ TEST_F(WidgetTestInteractive, SystemModalWindowReleasesCapture) {
|
|
|
| #endif
|
|
|
| +TEST_F(WidgetTestInteractive, CanActivateFlagIsHonored) {
|
| + Widget widget;
|
| + Widget::InitParams init_params =
|
| + CreateParams(Widget::InitParams::TYPE_WINDOW);
|
| + init_params.bounds = gfx::Rect(0, 0, 200, 200);
|
| + init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
|
| + init_params.activatable = Widget::InitParams::ACTIVATABLE_NO;
|
| +#if !defined(OS_CHROMEOS)
|
| + init_params.native_widget = new DesktopNativeWidgetAura(&widget);
|
| +#endif // !defined(OS_CHROMEOS)
|
| + widget.Init(init_params);
|
| +
|
| + widget.Show();
|
| + EXPECT_FALSE(widget.IsActive());
|
| +}
|
| +
|
| +// Test that touch selection quick menu is not activated when opened.
|
| +TEST_F(WidgetTestInteractive, TouchSelectionQuickMenuIsNotActivated) {
|
| + CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableTouchEditing);
|
| +#if defined(OS_WIN)
|
| + views_delegate().set_use_desktop_native_widgets(true);
|
| +#endif // !defined(OS_WIN)
|
| +
|
| + Widget widget;
|
| + Widget::InitParams init_params =
|
| + CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
|
| + init_params.bounds = gfx::Rect(0, 0, 200, 200);
|
| + init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
|
| + widget.Init(init_params);
|
| +
|
| + Textfield* textfield = new Textfield;
|
| + textfield->SetBounds(0, 0, 200, 20);
|
| + textfield->SetText(base::ASCIIToUTF16("some text"));
|
| + widget.GetRootView()->AddChildView(textfield);
|
| +
|
| + widget.Show();
|
| + textfield->RequestFocus();
|
| + textfield->SelectAll(true);
|
| +
|
| + RunPendingMessages();
|
| +
|
| + aura::test::EventGenerator generator(widget.GetNativeView()->GetRootWindow());
|
| + generator.GestureTapAt(gfx::Point(10, 10));
|
| + ShowTouchSelectionQuickMenuImmediately(textfield);
|
| +
|
| + EXPECT_TRUE(textfield->HasFocus());
|
| + EXPECT_TRUE(widget.IsActive());
|
| + EXPECT_TRUE(TouchSelectionQuickMenuIsVisible(textfield));
|
| +}
|
| +
|
| namespace {
|
|
|
| // Used to veirfy OnMouseCaptureLost() has been invoked.
|
|
|