| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> | 
| 6 | 6 | 
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" | 
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" | 
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" | 
| 10 #include "chrome/browser/accessibility/accessibility_extension_api.h" | 10 #include "chrome/browser/accessibility/accessibility_extension_api.h" | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 41 | 41 | 
| 42 using base::ASCIIToUTF16; | 42 using base::ASCIIToUTF16; | 
| 43 | 43 | 
| 44 class AccessibilityViewsDelegate : public views::TestViewsDelegate { | 44 class AccessibilityViewsDelegate : public views::TestViewsDelegate { | 
| 45  public: | 45  public: | 
| 46   AccessibilityViewsDelegate() {} | 46   AccessibilityViewsDelegate() {} | 
| 47   virtual ~AccessibilityViewsDelegate() {} | 47   virtual ~AccessibilityViewsDelegate() {} | 
| 48 | 48 | 
| 49   // Overridden from views::TestViewsDelegate: | 49   // Overridden from views::TestViewsDelegate: | 
| 50   virtual void NotifyAccessibilityEvent( | 50   virtual void NotifyAccessibilityEvent( | 
| 51       views::View* view, ui::AXEvent event_type) OVERRIDE { | 51       views::View* view, ui::AXEvent event_type) override { | 
| 52     AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent( | 52     AccessibilityEventRouterViews::GetInstance()->HandleAccessibilityEvent( | 
| 53         view, event_type); | 53         view, event_type); | 
| 54   } | 54   } | 
| 55 | 55 | 
| 56  private: | 56  private: | 
| 57   DISALLOW_COPY_AND_ASSIGN(AccessibilityViewsDelegate); | 57   DISALLOW_COPY_AND_ASSIGN(AccessibilityViewsDelegate); | 
| 58 }; | 58 }; | 
| 59 | 59 | 
| 60 class AccessibilityWindowDelegate : public views::WidgetDelegate { | 60 class AccessibilityWindowDelegate : public views::WidgetDelegate { | 
| 61  public: | 61  public: | 
| 62   explicit AccessibilityWindowDelegate(views::View* contents) | 62   explicit AccessibilityWindowDelegate(views::View* contents) | 
| 63       : contents_(contents) { } | 63       : contents_(contents) { } | 
| 64 | 64 | 
| 65   // Overridden from views::WidgetDelegate: | 65   // Overridden from views::WidgetDelegate: | 
| 66   virtual void DeleteDelegate() OVERRIDE { delete this; } | 66   virtual void DeleteDelegate() override { delete this; } | 
| 67   virtual views::View* GetContentsView() OVERRIDE { return contents_; } | 67   virtual views::View* GetContentsView() override { return contents_; } | 
| 68   virtual const views::Widget* GetWidget() const OVERRIDE { | 68   virtual const views::Widget* GetWidget() const override { | 
| 69     return contents_->GetWidget(); | 69     return contents_->GetWidget(); | 
| 70   } | 70   } | 
| 71   virtual views::Widget* GetWidget() OVERRIDE { return contents_->GetWidget(); } | 71   virtual views::Widget* GetWidget() override { return contents_->GetWidget(); } | 
| 72 | 72 | 
| 73  private: | 73  private: | 
| 74   views::View* contents_; | 74   views::View* contents_; | 
| 75 | 75 | 
| 76   DISALLOW_COPY_AND_ASSIGN(AccessibilityWindowDelegate); | 76   DISALLOW_COPY_AND_ASSIGN(AccessibilityWindowDelegate); | 
| 77 }; | 77 }; | 
| 78 | 78 | 
| 79 class ViewWithNameAndRole : public views::View { | 79 class ViewWithNameAndRole : public views::View { | 
| 80  public: | 80  public: | 
| 81   explicit ViewWithNameAndRole(const base::string16& name, | 81   explicit ViewWithNameAndRole(const base::string16& name, | 
| 82                                ui::AXRole role) | 82                                ui::AXRole role) | 
| 83       : name_(name), | 83       : name_(name), | 
| 84         role_(role) { | 84         role_(role) { | 
| 85   } | 85   } | 
| 86 | 86 | 
| 87   virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE { | 87   virtual void GetAccessibleState(ui::AXViewState* state) override { | 
| 88     views::View::GetAccessibleState(state); | 88     views::View::GetAccessibleState(state); | 
| 89     state->name = name_; | 89     state->name = name_; | 
| 90     state->role = role_; | 90     state->role = role_; | 
| 91   } | 91   } | 
| 92 | 92 | 
| 93   void set_name(const base::string16& name) { name_ = name; } | 93   void set_name(const base::string16& name) { name_ = name; } | 
| 94 | 94 | 
| 95  private: | 95  private: | 
| 96   base::string16 name_; | 96   base::string16 name_; | 
| 97   ui::AXRole role_; | 97   ui::AXRole role_; | 
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 472     menu_model_->AddItem(IDC_MENU_INVISIBLE, ASCIIToUTF16("Invisible")); | 472     menu_model_->AddItem(IDC_MENU_INVISIBLE, ASCIIToUTF16("Invisible")); | 
| 473     menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); | 473     menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); | 
| 474     menu_model_->AddItem(IDC_MENU_ITEM_3, ASCIIToUTF16("Item 3")); | 474     menu_model_->AddItem(IDC_MENU_ITEM_3, ASCIIToUTF16("Item 3")); | 
| 475 | 475 | 
| 476     menu_adapter_.reset(new views::MenuModelAdapter(menu_model_.get())); | 476     menu_adapter_.reset(new views::MenuModelAdapter(menu_model_.get())); | 
| 477     views::MenuItemView* menu_view = menu_adapter_->CreateMenu(); | 477     views::MenuItemView* menu_view = menu_adapter_->CreateMenu(); | 
| 478     menu_runner_.reset(new views::MenuRunner(menu_view, 0)); | 478     menu_runner_.reset(new views::MenuRunner(menu_view, 0)); | 
| 479     return menu_view; | 479     return menu_view; | 
| 480   } | 480   } | 
| 481 | 481 | 
| 482   virtual bool IsCommandIdChecked(int command_id) const OVERRIDE { | 482   virtual bool IsCommandIdChecked(int command_id) const override { | 
| 483     return false; | 483     return false; | 
| 484   } | 484   } | 
| 485 | 485 | 
| 486   virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE { | 486   virtual bool IsCommandIdEnabled(int command_id) const override { | 
| 487     return true; | 487     return true; | 
| 488   } | 488   } | 
| 489 | 489 | 
| 490   virtual bool IsCommandIdVisible(int command_id) const OVERRIDE { | 490   virtual bool IsCommandIdVisible(int command_id) const override { | 
| 491     return command_id != IDC_MENU_INVISIBLE; | 491     return command_id != IDC_MENU_INVISIBLE; | 
| 492   } | 492   } | 
| 493 | 493 | 
| 494   virtual bool GetAcceleratorForCommandId( | 494   virtual bool GetAcceleratorForCommandId( | 
| 495       int command_id, | 495       int command_id, | 
| 496       ui::Accelerator* accelerator) OVERRIDE { | 496       ui::Accelerator* accelerator) override { | 
| 497     return false; | 497     return false; | 
| 498   } | 498   } | 
| 499 | 499 | 
| 500   virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE { | 500   virtual void ExecuteCommand(int command_id, int event_flags) override { | 
| 501   } | 501   } | 
| 502 | 502 | 
| 503  private: | 503  private: | 
| 504   scoped_ptr<ui::SimpleMenuModel> menu_model_; | 504   scoped_ptr<ui::SimpleMenuModel> menu_model_; | 
| 505   scoped_ptr<views::MenuModelAdapter> menu_adapter_; | 505   scoped_ptr<views::MenuModelAdapter> menu_adapter_; | 
| 506   scoped_ptr<views::MenuRunner> menu_runner_; | 506   scoped_ptr<views::MenuRunner> menu_runner_; | 
| 507 | 507 | 
| 508   DISALLOW_COPY_AND_ASSIGN(SimpleMenuDelegate); | 508   DISALLOW_COPY_AND_ASSIGN(SimpleMenuDelegate); | 
| 509 }; | 509 }; | 
| 510 | 510 | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 532 | 532 | 
| 533     AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount( | 533     AccessibilityEventRouterViews::RecursiveGetMenuItemIndexAndCount( | 
| 534         menu_container, | 534         menu_container, | 
| 535         menu->GetMenuItemByID(kTestCases[i].command_id), | 535         menu->GetMenuItemByID(kTestCases[i].command_id), | 
| 536         &index, | 536         &index, | 
| 537         &count); | 537         &count); | 
| 538     EXPECT_EQ(kTestCases[i].expected_index, index) << "Case " << i; | 538     EXPECT_EQ(kTestCases[i].expected_index, index) << "Case " << i; | 
| 539     EXPECT_EQ(kTestCases[i].expected_count, count) << "Case " << i; | 539     EXPECT_EQ(kTestCases[i].expected_count, count) << "Case " << i; | 
| 540   } | 540   } | 
| 541 } | 541 } | 
| OLD | NEW | 
|---|