Chromium Code Reviews| Index: ios/chrome/browser/ui/context_menu/context_menu_coordinator_unittest.mm |
| diff --git a/ios/chrome/browser/ui/context_menu/context_menu_coordinator_unittest.mm b/ios/chrome/browser/ui/context_menu/context_menu_coordinator_unittest.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e81f2e106b2046d038cc7d1b6ac03268d18394cf |
| --- /dev/null |
| +++ b/ios/chrome/browser/ui/context_menu/context_menu_coordinator_unittest.mm |
| @@ -0,0 +1,44 @@ |
| +// Copyright 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "ios/chrome/browser/ui/context_menu/context_menu_coordinator.h" |
| + |
| +#import <UIKit/UIKit.h> |
| + |
| +#include "base/mac/scoped_nsobject.h" |
| +#import "ios/web/public/web_state/context_menu_params.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "testing/platform_test.h" |
| + |
| +// Fixture to test ContextMenuCoordinator. |
| +class ContextMenuCoordinatorTest : public PlatformTest { |
| + public: |
| + ContextMenuCoordinatorTest() { |
| + window_.reset( |
| + [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]); |
| + [window_ makeKeyAndVisible]; |
| + } |
| + |
| + protected: |
| + base::scoped_nsobject<ContextMenuCoordinator> menu_coordinator_; |
| + base::scoped_nsobject<UIWindow> window_; |
| +}; |
| + |
| +// Tests the context menu reports as visible after presenting. |
| +TEST_F(ContextMenuCoordinatorTest, DisplayContextMenu) { |
| + web::ContextMenuParams params; |
| + params.location = CGPointZero; |
| + params.view.reset([window_ retain]); |
| + menu_coordinator_.reset( |
| + [[ContextMenuCoordinator alloc] initWithContextMenuParams:params]); |
|
Eugene But (OOO till 7-30)
2016/05/19 19:00:06
initWithViewController: ?
michaeldo
2016/05/20 16:34:24
This didn't get updated before. Fixed now with imp
|
| + |
| + [menu_coordinator_ addItemWithTitle:@"foo" action:nil]; |
| + [menu_coordinator_ addItemWithTitle:@"bar" |
| + action:^{ |
|
Jackie Quinn
2016/05/19 15:39:28
Why one nil action and one ^{} action? Also, would
michaeldo
2016/05/19 15:57:30
The nil vs block (even though it's empty) are simp
Eugene But (OOO till 7-30)
2016/05/19 19:00:06
Now when your class takes view controller you can
michaeldo
2016/05/20 16:34:24
You're definitely right, I've improved the unittes
|
| + }]; |
| + |
| + [menu_coordinator_ start]; |
| + |
| + EXPECT_TRUE([menu_coordinator_ isVisible]); |
| +} |