| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/mac/foundation_util.h" | 5 #include "base/mac/foundation_util.h" |
| 6 #include "base/mac/scoped_nsobject.h" | 6 #include "base/mac/scoped_nsobject.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "skia/ext/skia_utils_mac.h" | 8 #include "skia/ext/skia_utils_mac.h" |
| 9 #import "testing/gtest_mac.h" | 9 #import "testing/gtest_mac.h" |
| 10 #include "ui/app_list/app_list_constants.h" | 10 #include "ui/app_list/app_list_constants.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 return owned_delegate_.get(); | 89 return owned_delegate_.get(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 NSColor* ButtonTitleColorAt(size_t index) { | 92 NSColor* ButtonTitleColorAt(size_t index) { |
| 93 NSDictionary* attributes = | 93 NSDictionary* attributes = |
| 94 [[[GetItemViewAt(index) cell] attributedTitle] attributesAtIndex:0 | 94 [[[GetItemViewAt(index) cell] attributedTitle] attributesAtIndex:0 |
| 95 effectiveRange:NULL]; | 95 effectiveRange:NULL]; |
| 96 return [attributes objectForKey:NSForegroundColorAttributeName]; | 96 return [attributes objectForKey:NSForegroundColorAttributeName]; |
| 97 } | 97 } |
| 98 | 98 |
| 99 virtual void SetUp() OVERRIDE { | 99 virtual void SetUp() override { |
| 100 owned_apps_grid_controller_.reset([[AppsGridController alloc] init]); | 100 owned_apps_grid_controller_.reset([[AppsGridController alloc] init]); |
| 101 owned_delegate_.reset(new AppListTestViewDelegate); | 101 owned_delegate_.reset(new AppListTestViewDelegate); |
| 102 [owned_apps_grid_controller_ setDelegate:owned_delegate_.get()]; | 102 [owned_apps_grid_controller_ setDelegate:owned_delegate_.get()]; |
| 103 AppsGridControllerTestHelper::SetUpWithGridController( | 103 AppsGridControllerTestHelper::SetUpWithGridController( |
| 104 owned_apps_grid_controller_.get()); | 104 owned_apps_grid_controller_.get()); |
| 105 | 105 |
| 106 [[test_window() contentView] addSubview:[apps_grid_controller_ view]]; | 106 [[test_window() contentView] addSubview:[apps_grid_controller_ view]]; |
| 107 [test_window() makePretendKeyWindowAndSetFirstResponder: | 107 [test_window() makePretendKeyWindowAndSetFirstResponder: |
| 108 [apps_grid_controller_ collectionViewAtPageIndex:0]]; | 108 [apps_grid_controller_ collectionViewAtPageIndex:0]]; |
| 109 } | 109 } |
| 110 | 110 |
| 111 virtual void TearDown() OVERRIDE { | 111 virtual void TearDown() override { |
| 112 [owned_apps_grid_controller_ setDelegate:NULL]; | 112 [owned_apps_grid_controller_ setDelegate:NULL]; |
| 113 owned_apps_grid_controller_.reset(); | 113 owned_apps_grid_controller_.reset(); |
| 114 AppsGridControllerTestHelper::TearDown(); | 114 AppsGridControllerTestHelper::TearDown(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ReplaceTestModel(int item_count) { | 117 void ReplaceTestModel(int item_count) { |
| 118 // Clear the delegate before reseting and destroying the model. | 118 // Clear the delegate before reseting and destroying the model. |
| 119 [owned_apps_grid_controller_ setDelegate:NULL]; | 119 [owned_apps_grid_controller_ setDelegate:NULL]; |
| 120 | 120 |
| 121 owned_delegate_->ReplaceTestModel(item_count); | 121 owned_delegate_->ReplaceTestModel(item_count); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 138 menu_model_(NULL), | 138 menu_model_(NULL), |
| 139 menu_ready_(true) { | 139 menu_ready_(true) { |
| 140 SetName(id); | 140 SetName(id); |
| 141 menu_model_.AddItem(0, base::UTF8ToUTF16("Menu For: " + id)); | 141 menu_model_.AddItem(0, base::UTF8ToUTF16("Menu For: " + id)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void SetMenuReadyForTesting(bool ready) { | 144 void SetMenuReadyForTesting(bool ready) { |
| 145 menu_ready_ = ready; | 145 menu_ready_ = ready; |
| 146 } | 146 } |
| 147 | 147 |
| 148 virtual ui::MenuModel* GetContextMenuModel() OVERRIDE { | 148 virtual ui::MenuModel* GetContextMenuModel() override { |
| 149 if (!menu_ready_) | 149 if (!menu_ready_) |
| 150 return NULL; | 150 return NULL; |
| 151 | 151 |
| 152 return &menu_model_; | 152 return &menu_model_; |
| 153 } | 153 } |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 ui::SimpleMenuModel menu_model_; | 156 ui::SimpleMenuModel menu_model_; |
| 157 bool menu_ready_; | 157 bool menu_ready_; |
| 158 | 158 |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 // Test that a button being held down with the left button does not also show | 982 // Test that a button being held down with the left button does not also show |
| 983 // a context menu. | 983 // a context menu. |
| 984 [GetItemViewAt(0) highlight:YES]; | 984 [GetItemViewAt(0) highlight:YES]; |
| 985 EXPECT_FALSE([page menuForEvent:mouse_at_cell_0]); | 985 EXPECT_FALSE([page menuForEvent:mouse_at_cell_0]); |
| 986 [GetItemViewAt(0) highlight:NO]; | 986 [GetItemViewAt(0) highlight:NO]; |
| 987 EXPECT_TRUE([page menuForEvent:mouse_at_cell_0]); | 987 EXPECT_TRUE([page menuForEvent:mouse_at_cell_0]); |
| 988 } | 988 } |
| 989 | 989 |
| 990 } // namespace test | 990 } // namespace test |
| 991 } // namespace app_list | 991 } // namespace app_list |
| OLD | NEW |