Chromium Code Reviews| Index: ios/chrome/browser/ui/context_menu/context_menu_wrangler_unittest.mm |
| diff --git a/ios/chrome/browser/ui/context_menu/context_menu_wrangler_unittest.mm b/ios/chrome/browser/ui/context_menu/context_menu_wrangler_unittest.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5ec6a6fb12a03ec4e3989fed616d3af0a6f479da |
| --- /dev/null |
| +++ b/ios/chrome/browser/ui/context_menu/context_menu_wrangler_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_wrangler.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 ContextMenuWrangler. |
| +class ContextMenuWranglerTest : public PlatformTest { |
| + public: |
| + ContextMenuWranglerTest() { |
| + _window.reset( |
| + [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]); |
| + [_window makeKeyAndVisible]; |
| + } |
| + |
| + protected: |
| + base::scoped_nsobject<ContextMenuWrangler> _menuWrangler; |
|
Eugene But (OOO till 7-30)
2016/05/13 01:23:56
s/_menuWrangler/menu_wrangler_
michaeldo
2016/05/17 18:03:03
Done.
|
| + base::scoped_nsobject<UIWindow> _window; |
|
Eugene But (OOO till 7-30)
2016/05/13 01:23:56
s/_window/window_
michaeldo
2016/05/17 18:03:03
Done.
|
| +}; |
| + |
| +// Tests the context menu reports as visible after presenting. |
| +TEST_F(ContextMenuWranglerTest, DisplayContextMenu) { |
| + web::ContextMenuParams params; |
| + params.location = CGPointZero; |
| + params.view.reset([_window retain]); |
| + _menuWrangler.reset( |
| + [[ContextMenuWrangler alloc] initWithContextMenuParams:params]); |
| + |
| + [_menuWrangler addItemWithTitle:@"foo" action:nil]; |
| + [_menuWrangler addItemWithTitle:@"bar" |
| + action:^{ |
| + }]; |
| + |
| + [_menuWrangler present]; |
| + |
| + EXPECT_TRUE([_menuWrangler isVisible]); |
| +} |