Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: ios/chrome/browser/ui/browser_view_controller_unittest.mm

Issue 2645653003: Expose thumbnails of pages to iOS share extensions. (Closed)
Patch Set: Addressed comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/ui/browser_view_controller.mm ('k') | ios/chrome/browser/ui/ui_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/browser_view_controller_unittest.mm
diff --git a/ios/chrome/browser/ui/browser_view_controller_unittest.mm b/ios/chrome/browser/ui/browser_view_controller_unittest.mm
index d31d8ee75a3f4bd1ea02fdc9ffc5338ac783c37e..2822da9cfa60d1ba9061808cd8fa99a08179f59b 100644
--- a/ios/chrome/browser/ui/browser_view_controller_unittest.mm
+++ b/ios/chrome/browser/ui/browser_view_controller_unittest.mm
@@ -66,6 +66,7 @@
#include "third_party/ocmock/gtest_support.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h"
+#include "ui/base/test/ios/ui_image_test_utils.h"
using web::NavigationManagerImpl;
using web::WebStateImpl;
@@ -406,18 +407,36 @@ TEST_F(BrowserViewControllerTest, TestSharePageCommandHandling) {
NSString* expectedTitle = @"title";
[(BVCTestTabMock*)tab_.get() setUrl:expectedUrl];
OCMockObject* tabMock = (OCMockObject*)tab_.get();
+ ios::ChromeBrowserState* ptr = chrome_browser_state_.get();
+ [[[tabMock stub] andReturnValue:OCMOCK_VALUE(ptr)] browserState];
[[[tabMock stub] andReturn:expectedTitle] title];
[[[tabMock stub] andReturn:expectedTitle] originalTitle];
- base::scoped_nsobject<ShareToData> expectedShareData([[ShareToData alloc]
- initWithURL:expectedUrl
- title:expectedTitle
- isOriginalTitle:YES
- isPagePrintable:YES]);
+
+ UIImage* tabSnapshot = ui::test::uiimage_utils::UIImageWithSizeAndSolidColor(
+ CGSizeMake(300, 400), [UIColor blueColor]);
+ [[[tabMock stub] andReturn:tabSnapshot] generateSnapshotWithOverlay:NO
+ visibleFrameOnly:YES];
OCMockObject* shareControllerMock = (OCMockObject*)shareController_.get();
// Passing non zero/nil |fromRect| and |inView| parameters to satisfy protocol
// requirements.
+ BOOL (^shareDataChecker)
+ (id value) = ^BOOL(id value) {
+ if (![value isMemberOfClass:ShareToData.class])
+ return NO;
+ ShareToData* shareToData = (ShareToData*)value;
+ CGSize size = CGSizeMake(40, 40);
+ BOOL thumbnailDataIsEqual = ui::test::uiimage_utils::UIImagesAreEqual(
+ shareToData.thumbnailGenerator(size),
+ ui::test::uiimage_utils::UIImageWithSizeAndSolidColor(
+ size, [UIColor blueColor]));
+ return shareToData.url == expectedUrl &&
+ [shareToData.title isEqual:expectedTitle] &&
+ shareToData.isOriginalTitle == YES &&
+ shareToData.isPagePrintable == NO && thumbnailDataIsEqual;
+ };
+
[[shareControllerMock expect]
- shareWithData:expectedShareData
+ shareWithData:[OCMArg checkWithBlock:shareDataChecker]
controller:bvc_
browserState:chrome_browser_state_.get()
shareToDelegate:bvc_
« no previous file with comments | « ios/chrome/browser/ui/browser_view_controller.mm ('k') | ios/chrome/browser/ui/ui_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698