| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/views/controls/textfield/textfield.h" | 5 #include "ui/views/controls/textfield/textfield.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 model_ = test_api_->model(); | 429 model_ = test_api_->model(); |
| 430 model_->ClearEditHistory(); | 430 model_->ClearEditHistory(); |
| 431 | 431 |
| 432 // Since the window type is activatable, showing the widget will also | 432 // Since the window type is activatable, showing the widget will also |
| 433 // activate it. Calling Activate directly is insufficient, since that does | 433 // activate it. Calling Activate directly is insufficient, since that does |
| 434 // not also _focus_ an aura::Window (i.e. using the FocusClient). Both the | 434 // not also _focus_ an aura::Window (i.e. using the FocusClient). Both the |
| 435 // widget and the textfield must have focus to properly handle input. | 435 // widget and the textfield must have focus to properly handle input. |
| 436 widget_->Show(); | 436 widget_->Show(); |
| 437 textfield_->RequestFocus(); | 437 textfield_->RequestFocus(); |
| 438 | 438 |
| 439 // On Mac, activation is asynchronous since desktop widgets are used. We | |
| 440 // don't want parallel tests to steal active status either, so fake it. | |
| 441 #if defined(OS_MACOSX) && !defined(USE_AURA) | |
| 442 fake_activation_ = test::WidgetTest::FakeWidgetIsActiveAlways(); | |
| 443 #endif | |
| 444 event_generator_.reset( | 439 event_generator_.reset( |
| 445 new ui::test::EventGenerator(GetContext(), widget_->GetNativeWindow())); | 440 new ui::test::EventGenerator(GetContext(), widget_->GetNativeWindow())); |
| 446 } | 441 } |
| 447 ui::MenuModel* GetContextMenuModel() { | 442 ui::MenuModel* GetContextMenuModel() { |
| 448 test_api_->UpdateContextMenu(); | 443 test_api_->UpdateContextMenu(); |
| 449 return test_api_->context_menu_contents(); | 444 return test_api_->context_menu_contents(); |
| 450 } | 445 } |
| 451 | 446 |
| 452 // True if native Mac keystrokes should be used (to avoid ifdef litter). | 447 // True if native Mac keystrokes should be used (to avoid ifdef litter). |
| 453 bool TestingNativeMac() { | 448 bool TestingNativeMac() { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 MockInputMethod* input_method_; | 648 MockInputMethod* input_method_; |
| 654 | 649 |
| 655 // Indicates how many times OnBeforeUserAction() is called. | 650 // Indicates how many times OnBeforeUserAction() is called. |
| 656 int on_before_user_action_; | 651 int on_before_user_action_; |
| 657 | 652 |
| 658 // Indicates how many times OnAfterUserAction() is called. | 653 // Indicates how many times OnAfterUserAction() is called. |
| 659 int on_after_user_action_; | 654 int on_after_user_action_; |
| 660 | 655 |
| 661 private: | 656 private: |
| 662 ui::ClipboardType copied_to_clipboard_; | 657 ui::ClipboardType copied_to_clipboard_; |
| 663 scoped_ptr<test::WidgetTest::FakeActivation> fake_activation_; | |
| 664 scoped_ptr<ui::test::EventGenerator> event_generator_; | 658 scoped_ptr<ui::test::EventGenerator> event_generator_; |
| 665 DISALLOW_COPY_AND_ASSIGN(TextfieldTest); | 659 DISALLOW_COPY_AND_ASSIGN(TextfieldTest); |
| 666 }; | 660 }; |
| 667 | 661 |
| 668 TEST_F(TextfieldTest, ModelChangesTest) { | 662 TEST_F(TextfieldTest, ModelChangesTest) { |
| 669 InitTextfield(); | 663 InitTextfield(); |
| 670 | 664 |
| 671 // TextfieldController::ContentsChanged() shouldn't be called when changing | 665 // TextfieldController::ContentsChanged() shouldn't be called when changing |
| 672 // text programmatically. | 666 // text programmatically. |
| 673 last_contents_.clear(); | 667 last_contents_.clear(); |
| (...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2575 | 2569 |
| 2576 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 2570 textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| 2577 ui::AXViewState state_protected; | 2571 ui::AXViewState state_protected; |
| 2578 textfield_->GetAccessibleState(&state_protected); | 2572 textfield_->GetAccessibleState(&state_protected); |
| 2579 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); | 2573 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, state_protected.role); |
| 2580 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); | 2574 EXPECT_EQ(ASCIIToUTF16("********"), state_protected.value); |
| 2581 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); | 2575 EXPECT_TRUE(state_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); |
| 2582 } | 2576 } |
| 2583 | 2577 |
| 2584 } // namespace views | 2578 } // namespace views |
| OLD | NEW |