| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 NSArray* subviews = [parent_->GetNativeView() subviews]; | 162 NSArray* subviews = [parent_->GetNativeView() subviews]; |
| 163 EXPECT_EQ(2u, [subviews count]); | 163 EXPECT_EQ(2u, [subviews count]); |
| 164 last_anchor_frame_ = [[subviews objectAtIndex:1] frame]; | 164 last_anchor_frame_ = [[subviews objectAtIndex:1] frame]; |
| 165 runner_->Cancel(); | 165 runner_->Cancel(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 DISALLOW_COPY_AND_ASSIGN(MenuRunnerCocoaTest); | 168 DISALLOW_COPY_AND_ASSIGN(MenuRunnerCocoaTest); |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 TEST_F(MenuRunnerCocoaTest, RunMenuAndCancel) { | 171 TEST_F(MenuRunnerCocoaTest, RunMenuAndCancel) { |
| 172 base::TimeDelta min_time = ui::EventTimeForNow(); | 172 base::TimeDelta min_time = (ui::EventTimeForNow() - base::TimeTicks()); |
| 173 | 173 |
| 174 MenuRunner::RunResult result = RunMenu(base::Bind( | 174 MenuRunner::RunResult result = RunMenu(base::Bind( |
| 175 &MenuRunnerCocoaTest::MenuCancelCallback, base::Unretained(this))); | 175 &MenuRunnerCocoaTest::MenuCancelCallback, base::Unretained(this))); |
| 176 | 176 |
| 177 EXPECT_EQ(MenuRunner::NORMAL_EXIT, result); | 177 EXPECT_EQ(MenuRunner::NORMAL_EXIT, result); |
| 178 EXPECT_FALSE(runner_->IsRunning()); | 178 EXPECT_FALSE(runner_->IsRunning()); |
| 179 | 179 |
| 180 EXPECT_GE(runner_->GetClosingEventTime(), min_time); | 180 EXPECT_GE(runner_->GetClosingEventTime(), min_time); |
| 181 EXPECT_LE(runner_->GetClosingEventTime(), ui::EventTimeForNow()); | 181 EXPECT_LE(runner_->GetClosingEventTime(), |
| 182 (ui::EventTimeForNow() - base::TimeTicks())); |
| 182 | 183 |
| 183 // Cancel again. | 184 // Cancel again. |
| 184 runner_->Cancel(); | 185 runner_->Cancel(); |
| 185 EXPECT_FALSE(runner_->IsRunning()); | 186 EXPECT_FALSE(runner_->IsRunning()); |
| 186 } | 187 } |
| 187 | 188 |
| 188 TEST_F(MenuRunnerCocoaTest, RunMenuAndDelete) { | 189 TEST_F(MenuRunnerCocoaTest, RunMenuAndDelete) { |
| 189 MenuRunner::RunResult result = RunMenu(base::Bind( | 190 MenuRunner::RunResult result = RunMenu(base::Bind( |
| 190 &MenuRunnerCocoaTest::MenuDeleteCallback, base::Unretained(this))); | 191 &MenuRunnerCocoaTest::MenuDeleteCallback, base::Unretained(this))); |
| 191 EXPECT_EQ(MenuRunner::MENU_DELETED, result); | 192 EXPECT_EQ(MenuRunner::MENU_DELETED, result); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // In RTL, Cocoa messes up the positioning unless the anchor rectangle is | 258 // In RTL, Cocoa messes up the positioning unless the anchor rectangle is |
| 258 // offset to the right of the view. The offset for the checkmark is also | 259 // offset to the right of the view. The offset for the checkmark is also |
| 259 // skipped, to give a better match to native behavior. | 260 // skipped, to give a better match to native behavior. |
| 260 base::i18n::SetICUDefaultLocale("he"); | 261 base::i18n::SetICUDefaultLocale("he"); |
| 261 RunMenuAt(anchor_rect); | 262 RunMenuAt(anchor_rect); |
| 262 EXPECT_EQ(combobox_rect.right(), last_anchor_frame_.origin.x); | 263 EXPECT_EQ(combobox_rect.right(), last_anchor_frame_.origin.x); |
| 263 } | 264 } |
| 264 | 265 |
| 265 } // namespace test | 266 } // namespace test |
| 266 } // namespace views | 267 } // namespace views |
| OLD | NEW |