| 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 g_no_mock_time = true; |
| 172 base::TimeDelta min_time = (ui::EventTimeForNow() - base::TimeTicks()); | 173 base::TimeDelta min_time = (ui::EventTimeForNow() - base::TimeTicks()); |
| 173 | 174 |
| 174 MenuRunner::RunResult result = RunMenu(base::Bind( | 175 MenuRunner::RunResult result = RunMenu(base::Bind( |
| 175 &MenuRunnerCocoaTest::MenuCancelCallback, base::Unretained(this))); | 176 &MenuRunnerCocoaTest::MenuCancelCallback, base::Unretained(this))); |
| 176 | 177 |
| 177 EXPECT_EQ(MenuRunner::NORMAL_EXIT, result); | 178 EXPECT_EQ(MenuRunner::NORMAL_EXIT, result); |
| 178 EXPECT_FALSE(runner_->IsRunning()); | 179 EXPECT_FALSE(runner_->IsRunning()); |
| 179 | 180 |
| 180 EXPECT_GE(runner_->GetClosingEventTime(), min_time); | 181 EXPECT_GE(runner_->GetClosingEventTime(), min_time); |
| 181 EXPECT_LE(runner_->GetClosingEventTime(), | 182 EXPECT_LE(runner_->GetClosingEventTime(), |
| 182 (ui::EventTimeForNow() - base::TimeTicks())); | 183 (ui::EventTimeForNow() - base::TimeTicks())); |
| 183 | 184 |
| 184 // Cancel again. | 185 // Cancel again. |
| 185 runner_->Cancel(); | 186 runner_->Cancel(); |
| 186 EXPECT_FALSE(runner_->IsRunning()); | 187 EXPECT_FALSE(runner_->IsRunning()); |
| 188 |
| 189 g_no_mock_time = false; |
| 187 } | 190 } |
| 188 | 191 |
| 189 TEST_F(MenuRunnerCocoaTest, RunMenuAndDelete) { | 192 TEST_F(MenuRunnerCocoaTest, RunMenuAndDelete) { |
| 190 MenuRunner::RunResult result = RunMenu(base::Bind( | 193 MenuRunner::RunResult result = RunMenu(base::Bind( |
| 191 &MenuRunnerCocoaTest::MenuDeleteCallback, base::Unretained(this))); | 194 &MenuRunnerCocoaTest::MenuDeleteCallback, base::Unretained(this))); |
| 192 EXPECT_EQ(MenuRunner::MENU_DELETED, result); | 195 EXPECT_EQ(MenuRunner::MENU_DELETED, result); |
| 193 } | 196 } |
| 194 | 197 |
| 195 // Ensure a menu can be safely released immediately after a call to Cancel() in | 198 // Ensure a menu can be safely released immediately after a call to Cancel() in |
| 196 // the same run loop iteration. | 199 // the same run loop iteration. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // In RTL, Cocoa messes up the positioning unless the anchor rectangle is | 261 // In RTL, Cocoa messes up the positioning unless the anchor rectangle is |
| 259 // offset to the right of the view. The offset for the checkmark is also | 262 // offset to the right of the view. The offset for the checkmark is also |
| 260 // skipped, to give a better match to native behavior. | 263 // skipped, to give a better match to native behavior. |
| 261 base::i18n::SetICUDefaultLocale("he"); | 264 base::i18n::SetICUDefaultLocale("he"); |
| 262 RunMenuAt(anchor_rect); | 265 RunMenuAt(anchor_rect); |
| 263 EXPECT_EQ(combobox_rect.right(), last_anchor_frame_.origin.x); | 266 EXPECT_EQ(combobox_rect.right(), last_anchor_frame_.origin.x); |
| 264 } | 267 } |
| 265 | 268 |
| 266 } // namespace test | 269 } // namespace test |
| 267 } // namespace views | 270 } // namespace views |
| OLD | NEW |