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

Side by Side Diff: ui/views/widget/widget_interactive_uitest.cc

Issue 154783002: Honor can_activate flag in ShowWindowWithState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 6 years, 7 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 unified diff | Download patch
« ui/views/widget/widget.cc ('K') | « ui/views/widget/widget.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h"
7 #include "base/path_service.h" 8 #include "base/path_service.h"
8 #include "base/run_loop.h" 9 #include "base/run_loop.h"
9 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h"
10 #include "ui/aura/client/focus_client.h" 12 #include "ui/aura/client/focus_client.h"
11 #include "ui/aura/env.h" 13 #include "ui/aura/env.h"
14 #include "ui/aura/test/event_generator.h"
12 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
13 #include "ui/aura/window_tree_host.h" 16 #include "ui/aura/window_tree_host.h"
14 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/base/ui_base_paths.h" 18 #include "ui/base/ui_base_paths.h"
19 #include "ui/base/ui_base_switches.h"
16 #include "ui/events/event_processor.h" 20 #include "ui/events/event_processor.h"
17 #include "ui/gfx/native_widget_types.h" 21 #include "ui/gfx/native_widget_types.h"
18 #include "ui/gl/gl_surface.h" 22 #include "ui/gl/gl_surface.h"
23 #include "ui/views/controls/textfield/textfield.h"
19 #include "ui/views/test/widget_test.h" 24 #include "ui/views/test/widget_test.h"
25 #include "ui/views/touchui/touch_selection_controller_impl.h"
20 #include "ui/views/widget/widget.h" 26 #include "ui/views/widget/widget.h"
21 #include "ui/views/window/dialog_delegate.h" 27 #include "ui/views/window/dialog_delegate.h"
22 #include "ui/wm/public/activation_client.h" 28 #include "ui/wm/public/activation_client.h"
23 29
24 #if !defined(OS_CHROMEOS) 30 #if !defined(OS_CHROMEOS)
25 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 31 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
26 #endif 32 #endif
27 33
28 #if defined(OS_WIN) 34 #if defined(OS_WIN)
29 #include "ui/views/win/hwnd_util.h" 35 #include "ui/views/win/hwnd_util.h"
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 modal_dialog_widget->Show(); 701 modal_dialog_widget->Show();
696 702
697 EXPECT_FALSE(top_level_window->HasCapture()); 703 EXPECT_FALSE(top_level_window->HasCapture());
698 704
699 modal_dialog_widget->CloseNow(); 705 modal_dialog_widget->CloseNow();
700 top_level_widget.CloseNow(); 706 top_level_widget.CloseNow();
701 } 707 }
702 708
703 #endif 709 #endif
704 710
711 TEST_F(WidgetTestInteractive, CanActivateFlagIsHonored) {
712 Widget widget;
713 Widget::InitParams init_params =
714 CreateParams(Widget::InitParams::TYPE_WINDOW);
715 init_params.bounds = gfx::Rect(0, 0, 200, 200);
716 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
717 init_params.can_activate = false;
718 #if !defined(OS_CHROMEOS)
719 init_params.native_widget = new DesktopNativeWidgetAura(&widget);
720 #endif // !defined(OS_CHROMEOS)
721 widget.Init(init_params);
722
723 widget.Show();
724 EXPECT_FALSE(widget.IsActive());
725 }
726
727 // Test that touch selection quick menu is not activated when opened.
728 TEST_F(WidgetTestInteractive, TouchSelectionQuickMenuIsNotActivated) {
729 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableTouchEditing);
730 TouchSelectionControllerImpl::SetOpenQuickMenuImmediatelyForTest(true);
731 #if defined(OS_WIN)
732 views_delegate().SetUseDesktopNativeWidgets(true);
733 #endif // !defined(OS_WIN)
734
735 Widget widget;
736 Widget::InitParams init_params =
737 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
738 init_params.bounds = gfx::Rect(0, 0, 200, 200);
739 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
740 widget.Init(init_params);
741
742 Textfield* textfield = new Textfield;
743 textfield->SetBounds(0, 0, 200, 20);
744 textfield->SetText(base::ASCIIToUTF16("some text"));
745 widget.GetRootView()->AddChildView(textfield);
746
747 widget.Show();
748 textfield->RequestFocus();
749 textfield->SelectAll(true);
750
751 RunPendingMessages();
752
753 aura::test::EventGenerator generator(widget.GetNativeView()->GetRootWindow());
754 generator.GestureTapAt(gfx::Point(10, 10));
755
756 EXPECT_TRUE(textfield->HasFocus());
757 EXPECT_TRUE(widget.IsActive());
sadrul 2014/05/15 12:52:02 Do you want to verify that the touch-selection men
mohsen 2014/05/16 15:56:09 Done.
758 }
759
705 namespace { 760 namespace {
706 761
707 // Used to veirfy OnMouseCaptureLost() has been invoked. 762 // Used to veirfy OnMouseCaptureLost() has been invoked.
708 class CaptureLostTrackingWidget : public Widget { 763 class CaptureLostTrackingWidget : public Widget {
709 public: 764 public:
710 CaptureLostTrackingWidget() : got_capture_lost_(false) {} 765 CaptureLostTrackingWidget() : got_capture_lost_(false) {}
711 virtual ~CaptureLostTrackingWidget() {} 766 virtual ~CaptureLostTrackingWidget() {}
712 767
713 bool GetAndClearGotCaptureLost() { 768 bool GetAndClearGotCaptureLost() {
714 bool value = got_capture_lost_; 769 bool value = got_capture_lost_;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> 942 ui::EventDispatchDetails details = widget1.GetNativeWindow()->
888 GetHost()->event_processor()->OnEventFromSource(&mouse_event); 943 GetHost()->event_processor()->OnEventFromSource(&mouse_event);
889 ASSERT_FALSE(details.dispatcher_destroyed); 944 ASSERT_FALSE(details.dispatcher_destroyed);
890 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); 945 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent());
891 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); 946 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent());
892 } 947 }
893 #endif 948 #endif
894 949
895 } // namespace test 950 } // namespace test
896 } // namespace views 951 } // namespace views
OLDNEW
« ui/views/widget/widget.cc ('K') | « ui/views/widget/widget.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698