| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/gfx/path.h" | 8 #include "app/gfx/path.h" |
| 9 #include "base/clipboard.h" | 9 #include "base/clipboard.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 TEST_F(ViewTest, MouseEvent) { | 299 TEST_F(ViewTest, MouseEvent) { |
| 300 TestView* v1 = new TestView(); | 300 TestView* v1 = new TestView(); |
| 301 v1->SetBounds(0, 0, 300, 300); | 301 v1->SetBounds(0, 0, 300, 300); |
| 302 | 302 |
| 303 TestView* v2 = new TestView(); | 303 TestView* v2 = new TestView(); |
| 304 v2->SetBounds (100, 100, 100, 100); | 304 v2->SetBounds (100, 100, 100, 100); |
| 305 | 305 |
| 306 views::WidgetWin window; | 306 views::WidgetWin window; |
| 307 window.set_delete_on_destroy(false); | 307 window.set_delete_on_destroy(false); |
| 308 window.set_window_style(WS_OVERLAPPEDWINDOW); | 308 window.set_window_style(WS_OVERLAPPEDWINDOW); |
| 309 window.Init(NULL, gfx::Rect(50, 50, 650, 650)); | 309 window.Init(NULL, gfx::Rect(50, 50, 650, 650), false); |
| 310 RootView* root = window.GetRootView(); | 310 RootView* root = window.GetRootView(); |
| 311 | 311 |
| 312 root->AddChildView(v1); | 312 root->AddChildView(v1); |
| 313 v1->AddChildView(v2); | 313 v1->AddChildView(v2); |
| 314 | 314 |
| 315 v1->Reset(); | 315 v1->Reset(); |
| 316 v2->Reset(); | 316 v2->Reset(); |
| 317 | 317 |
| 318 MouseEvent pressed(Event::ET_MOUSE_PRESSED, | 318 MouseEvent pressed(Event::ET_MOUSE_PRESSED, |
| 319 110, | 319 110, |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 TEST_F(ViewTest, TextfieldCutCopyPaste) { | 640 TEST_F(ViewTest, TextfieldCutCopyPaste) { |
| 641 views::ViewsDelegate::views_delegate = new TestViewsDelegate; | 641 views::ViewsDelegate::views_delegate = new TestViewsDelegate; |
| 642 | 642 |
| 643 const std::wstring kNormalText = L"Normal"; | 643 const std::wstring kNormalText = L"Normal"; |
| 644 const std::wstring kReadOnlyText = L"Read only"; | 644 const std::wstring kReadOnlyText = L"Read only"; |
| 645 const std::wstring kPasswordText = L"Password! ** Secret stuff **"; | 645 const std::wstring kPasswordText = L"Password! ** Secret stuff **"; |
| 646 | 646 |
| 647 Clipboard clipboard; | 647 Clipboard clipboard; |
| 648 | 648 |
| 649 WidgetWin* window = new WidgetWin; | 649 WidgetWin* window = new WidgetWin; |
| 650 window->Init(NULL, gfx::Rect(0, 0, 100, 100)); | 650 window->Init(NULL, gfx::Rect(0, 0, 100, 100), true); |
| 651 RootView* root_view = window->GetRootView(); | 651 RootView* root_view = window->GetRootView(); |
| 652 | 652 |
| 653 Textfield* normal = new Textfield(); | 653 Textfield* normal = new Textfield(); |
| 654 Textfield* read_only = new Textfield(); | 654 Textfield* read_only = new Textfield(); |
| 655 read_only->SetReadOnly(true); | 655 read_only->SetReadOnly(true); |
| 656 Textfield* password = new Textfield(Textfield::STYLE_PASSWORD); | 656 Textfield* password = new Textfield(Textfield::STYLE_PASSWORD); |
| 657 | 657 |
| 658 root_view->AddChildView(normal); | 658 root_view->AddChildView(normal); |
| 659 root_view->AddChildView(read_only); | 659 root_view->AddChildView(read_only); |
| 660 root_view->AddChildView(password); | 660 root_view->AddChildView(password); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 TEST_F(ViewTest, ActivateAccelerator) { | 762 TEST_F(ViewTest, ActivateAccelerator) { |
| 763 // Register a keyboard accelerator before the view is added to a window. | 763 // Register a keyboard accelerator before the view is added to a window. |
| 764 views::Accelerator return_accelerator(VK_RETURN, false, false, false); | 764 views::Accelerator return_accelerator(VK_RETURN, false, false, false); |
| 765 TestView* view = new TestView(); | 765 TestView* view = new TestView(); |
| 766 view->Reset(); | 766 view->Reset(); |
| 767 view->AddAccelerator(return_accelerator); | 767 view->AddAccelerator(return_accelerator); |
| 768 EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0); | 768 EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 0); |
| 769 | 769 |
| 770 // Create a window and add the view as its child. | 770 // Create a window and add the view as its child. |
| 771 WidgetWin window; | 771 WidgetWin window; |
| 772 window.Init(NULL, gfx::Rect(0, 0, 100, 100)); | 772 window.Init(NULL, gfx::Rect(0, 0, 100, 100), true); |
| 773 window.set_delete_on_destroy(false); | 773 window.set_delete_on_destroy(false); |
| 774 window.set_window_style(WS_OVERLAPPEDWINDOW); | 774 window.set_window_style(WS_OVERLAPPEDWINDOW); |
| 775 RootView* root = window.GetRootView(); | 775 RootView* root = window.GetRootView(); |
| 776 root->AddChildView(view); | 776 root->AddChildView(view); |
| 777 | 777 |
| 778 // Get the focus manager. | 778 // Get the focus manager. |
| 779 views::FocusManager* focus_manager = | 779 views::FocusManager* focus_manager = |
| 780 views::FocusManager::GetFocusManagerForNativeView(window.GetNativeView()); | 780 views::FocusManager::GetFocusManager(window.GetNativeView()); |
| 781 ASSERT_TRUE(focus_manager); | 781 ASSERT_TRUE(focus_manager); |
| 782 | 782 |
| 783 // Hit the return key and see if it takes effect. | 783 // Hit the return key and see if it takes effect. |
| 784 EXPECT_TRUE(focus_manager->ProcessAccelerator(return_accelerator)); | 784 EXPECT_TRUE(focus_manager->ProcessAccelerator(return_accelerator)); |
| 785 EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1); | 785 EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1); |
| 786 | 786 |
| 787 // Hit the escape key. Nothing should happen. | 787 // Hit the escape key. Nothing should happen. |
| 788 views::Accelerator escape_accelerator(VK_ESCAPE, false, false, false); | 788 views::Accelerator escape_accelerator(VK_ESCAPE, false, false, false); |
| 789 EXPECT_FALSE(focus_manager->ProcessAccelerator(escape_accelerator)); | 789 EXPECT_FALSE(focus_manager->ProcessAccelerator(escape_accelerator)); |
| 790 EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1); | 790 EXPECT_EQ(view->accelerator_count_map_[return_accelerator], 1); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 cancel_button_(NULL) { | 1025 cancel_button_(NULL) { |
| 1026 } | 1026 } |
| 1027 | 1027 |
| 1028 virtual void SetUp() { | 1028 virtual void SetUp() { |
| 1029 dialog_view_ = new TestDialogView(); | 1029 dialog_view_ = new TestDialogView(); |
| 1030 views::Window* window = | 1030 views::Window* window = |
| 1031 views::Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 100, 100), | 1031 views::Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 100, 100), |
| 1032 dialog_view_); | 1032 dialog_view_); |
| 1033 window->Show(); | 1033 window->Show(); |
| 1034 native_window_ = window->GetNativeWindow(); | 1034 native_window_ = window->GetNativeWindow(); |
| 1035 focus_manager_ = FocusManager::GetFocusManagerForNativeView(native_window_); | 1035 focus_manager_ = FocusManager::GetFocusManager(native_window_); |
| 1036 client_view_ = | 1036 client_view_ = |
| 1037 static_cast<views::DialogClientView*>(window->GetClientView()); | 1037 static_cast<views::DialogClientView*>(window->GetClientView()); |
| 1038 ok_button_ = client_view_->ok_button(); | 1038 ok_button_ = client_view_->ok_button(); |
| 1039 cancel_button_ = client_view_->cancel_button(); | 1039 cancel_button_ = client_view_->cancel_button(); |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 void SimularePressingEnterAndCheckDefaultButton(ButtonID button_id) { | 1042 void SimularePressingEnterAndCheckDefaultButton(ButtonID button_id) { |
| 1043 #if defined(OS_WIN) | 1043 #if defined(OS_WIN) |
| 1044 focus_manager_->OnKeyDown(native_window_, WM_KEYDOWN, VK_RETURN, 0); | 1044 focus_manager_->OnKeyDown(native_window_, WM_KEYDOWN, VK_RETURN, 0); |
| 1045 #else | 1045 #else |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 SimularePressingEnterAndCheckDefaultButton(OK); | 1120 SimularePressingEnterAndCheckDefaultButton(OK); |
| 1121 | 1121 |
| 1122 // Focus the cancel button. | 1122 // Focus the cancel button. |
| 1123 client_view_->FocusWillChange(NULL, cancel_button_); | 1123 client_view_->FocusWillChange(NULL, cancel_button_); |
| 1124 EXPECT_FALSE(ok_button_->is_default()); | 1124 EXPECT_FALSE(ok_button_->is_default()); |
| 1125 EXPECT_TRUE(cancel_button_->is_default()); | 1125 EXPECT_TRUE(cancel_button_->is_default()); |
| 1126 EXPECT_FALSE(dialog_view_->button1_->is_default()); | 1126 EXPECT_FALSE(dialog_view_->button1_->is_default()); |
| 1127 EXPECT_FALSE(dialog_view_->button2_->is_default()); | 1127 EXPECT_FALSE(dialog_view_->button2_->is_default()); |
| 1128 SimularePressingEnterAndCheckDefaultButton(CANCEL); | 1128 SimularePressingEnterAndCheckDefaultButton(CANCEL); |
| 1129 } | 1129 } |
| OLD | NEW |