Chromium Code Reviews| 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 #import "ui/views/controls/menu/menu_runner_impl_cocoa.h" | 5 #import "ui/views/controls/menu/menu_runner_impl_cocoa.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 void RunMenuAtCallback() { | 158 void RunMenuAtCallback() { |
| 159 NSArray* subviews = [parent_->GetNativeView() subviews]; | 159 NSArray* subviews = [parent_->GetNativeView() subviews]; |
| 160 EXPECT_EQ(2u, [subviews count]); | 160 EXPECT_EQ(2u, [subviews count]); |
| 161 last_anchor_frame_ = [[subviews objectAtIndex:1] frame]; | 161 last_anchor_frame_ = [[subviews objectAtIndex:1] frame]; |
| 162 runner_->Cancel(); | 162 runner_->Cancel(); |
| 163 } | 163 } |
| 164 | 164 |
| 165 DISALLOW_COPY_AND_ASSIGN(MenuRunnerCocoaTest); | 165 DISALLOW_COPY_AND_ASSIGN(MenuRunnerCocoaTest); |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 TEST_F(MenuRunnerCocoaTest, RunMenuAndCancel) { | 168 TEST_F(MenuRunnerCocoaTest, RunMenkjuAndCancel) { |
|
sadrul
2016/05/25 20:22:10
unrename?
majidvp
2016/05/27 14:34:15
Done.
| |
| 169 base::TimeDelta min_time = ui::EventTimeForNow(); | 169 base::TimeDelta min_time = (ui::EventTimeForNow() - base::TimeTicks()); |
| 170 | 170 |
| 171 MenuRunner::RunResult result = RunMenu(base::Bind( | 171 MenuRunner::RunResult result = RunMenu(base::Bind( |
| 172 &MenuRunnerCocoaTest::MenuCancelCallback, base::Unretained(this))); | 172 &MenuRunnerCocoaTest::MenuCancelCallback, base::Unretained(this))); |
| 173 | 173 |
| 174 EXPECT_EQ(MenuRunner::NORMAL_EXIT, result); | 174 EXPECT_EQ(MenuRunner::NORMAL_EXIT, result); |
| 175 EXPECT_FALSE(runner_->IsRunning()); | 175 EXPECT_FALSE(runner_->IsRunning()); |
| 176 | 176 |
| 177 EXPECT_GE(runner_->GetClosingEventTime(), min_time); | 177 EXPECT_GE(runner_->GetClosingEventTime(), min_time); |
| 178 EXPECT_LE(runner_->GetClosingEventTime(), ui::EventTimeForNow()); | 178 EXPECT_LE(runner_->GetClosingEventTime(), |
| 179 (ui::EventTimeForNow() - base::TimeTicks())); | |
|
sadrul
2016/05/25 20:22:10
I assume addressing the TODO in menu_controller.h
majidvp
2016/05/27 14:34:15
Yes indeed.
| |
| 179 | 180 |
| 180 // Cancel again. | 181 // Cancel again. |
| 181 runner_->Cancel(); | 182 runner_->Cancel(); |
| 182 EXPECT_FALSE(runner_->IsRunning()); | 183 EXPECT_FALSE(runner_->IsRunning()); |
| 183 } | 184 } |
| 184 | 185 |
| 185 TEST_F(MenuRunnerCocoaTest, RunMenuAndDelete) { | 186 TEST_F(MenuRunnerCocoaTest, RunMenuAndDelete) { |
| 186 MenuRunner::RunResult result = RunMenu(base::Bind( | 187 MenuRunner::RunResult result = RunMenu(base::Bind( |
| 187 &MenuRunnerCocoaTest::MenuDeleteCallback, base::Unretained(this))); | 188 &MenuRunnerCocoaTest::MenuDeleteCallback, base::Unretained(this))); |
| 188 EXPECT_EQ(MenuRunner::MENU_DELETED, result); | 189 EXPECT_EQ(MenuRunner::MENU_DELETED, result); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 // In RTL, Cocoa messes up the positioning unless the anchor rectangle is | 255 // In RTL, Cocoa messes up the positioning unless the anchor rectangle is |
| 255 // offset to the right of the view. The offset for the checkmark is also | 256 // offset to the right of the view. The offset for the checkmark is also |
| 256 // skipped, to give a better match to native behavior. | 257 // skipped, to give a better match to native behavior. |
| 257 base::i18n::SetICUDefaultLocale("he"); | 258 base::i18n::SetICUDefaultLocale("he"); |
| 258 RunMenuAt(anchor_rect); | 259 RunMenuAt(anchor_rect); |
| 259 EXPECT_EQ(combobox_rect.right(), last_anchor_frame_.origin.x); | 260 EXPECT_EQ(combobox_rect.right(), last_anchor_frame_.origin.x); |
| 260 } | 261 } |
| 261 | 262 |
| 262 } // namespace test | 263 } // namespace test |
| 263 } // namespace views | 264 } // namespace views |
| OLD | NEW |