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

Side by Side Diff: ios/chrome/browser/ui/activity_services/chrome_activity_item_thumbnail_generator_unittest.mm

Issue 2689533002: [ObjC ARC] Converts ios/chrome/browser/ui/activity_services:unit_tests to ARC. (Closed)
Patch Set: nit 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 unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/ui/activity_services/activity_type_util_unittest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "ios/chrome/browser/ui/activity_services/chrome_activity_item_thumbnail_ generator.h" 5 #import "ios/chrome/browser/ui/activity_services/chrome_activity_item_thumbnail_ generator.h"
6 6
7 #include "base/mac/scoped_nsobject.h"
8 #import "ios/chrome/browser/browser_state/test_chrome_browser_state.h" 7 #import "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
9 #include "ios/chrome/browser/tabs/tab.h" 8 #include "ios/chrome/browser/tabs/tab.h"
10 #include "testing/platform_test.h" 9 #include "testing/platform_test.h"
11 #import "third_party/ocmock/OCMock/OCMock.h" 10 #import "third_party/ocmock/OCMock/OCMock.h"
12 #include "ui/base/test/ios/ui_image_test_utils.h" 11 #include "ui/base/test/ios/ui_image_test_utils.h"
13 12
13 #if !defined(__has_feature) || !__has_feature(objc_arc)
14 #error "This file requires ARC support."
15 #endif
16
14 namespace { 17 namespace {
15 18
16 class ChromeActivityItemThumbnailGeneratorTest : public PlatformTest { 19 class ChromeActivityItemThumbnailGeneratorTest : public PlatformTest {
17 protected: 20 protected:
18 void SetUp() override { 21 void SetUp() override {
19 tab_.reset([[OCMockObject niceMockForClass:[Tab class]] retain]); 22 tab_ = [OCMockObject niceMockForClass:[Tab class]];
20 23
21 UIImage* snapshot = ui::test::uiimage_utils::UIImageWithSizeAndSolidColor( 24 UIImage* snapshot = ui::test::uiimage_utils::UIImageWithSizeAndSolidColor(
22 CGSizeMake(400, 300), [UIColor redColor]); 25 CGSizeMake(400, 300), [UIColor redColor]);
23 26
24 [[[tab_ stub] andReturn:snapshot] generateSnapshotWithOverlay:NO 27 [[[tab_ stub] andReturn:snapshot] generateSnapshotWithOverlay:NO
25 visibleFrameOnly:YES]; 28 visibleFrameOnly:YES];
26 } 29 }
27 30
28 void SetBrowserStateOnTab(bool incognito) { 31 void SetBrowserStateOnTab(bool incognito) {
29 TestChromeBrowserState::Builder test_cbs_builder; 32 TestChromeBrowserState::Builder test_cbs_builder;
30 chrome_browser_state_ = test_cbs_builder.Build(); 33 chrome_browser_state_ = test_cbs_builder.Build();
31 ios::ChromeBrowserState* browserState = 34 ios::ChromeBrowserState* browserState =
32 incognito ? chrome_browser_state_->GetOffTheRecordChromeBrowserState() 35 incognito ? chrome_browser_state_->GetOffTheRecordChromeBrowserState()
33 : chrome_browser_state_.get(); 36 : chrome_browser_state_.get();
34 [[[tab_ stub] andReturnValue:OCMOCK_VALUE(browserState)] browserState]; 37 [[[tab_ stub] andReturnValue:OCMOCK_VALUE(browserState)] browserState];
35 } 38 }
36 39
37 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; 40 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
38 base::scoped_nsobject<id> tab_; 41 id tab_;
39 }; 42 };
40 43
41 TEST_F(ChromeActivityItemThumbnailGeneratorTest, ThumbnailForNonIncognitoTab) { 44 TEST_F(ChromeActivityItemThumbnailGeneratorTest, ThumbnailForNonIncognitoTab) {
42 SetBrowserStateOnTab(false); 45 SetBrowserStateOnTab(false);
43 CGSize size = CGSizeMake(50, 50); 46 CGSize size = CGSizeMake(50, 50);
44 ThumbnailGeneratorBlock generatorBlock = 47 ThumbnailGeneratorBlock generatorBlock =
45 activity_services::ThumbnailGeneratorForTab(tab_); 48 activity_services::ThumbnailGeneratorForTab(tab_);
46 EXPECT_TRUE(generatorBlock); 49 EXPECT_TRUE(generatorBlock);
47 UIImage* thumbnail = generatorBlock(size); 50 UIImage* thumbnail = generatorBlock(size);
48 EXPECT_TRUE(thumbnail); 51 EXPECT_TRUE(thumbnail);
49 EXPECT_TRUE(CGSizeEqualToSize(thumbnail.size, size)); 52 EXPECT_TRUE(CGSizeEqualToSize(thumbnail.size, size));
50 } 53 }
51 54
52 TEST_F(ChromeActivityItemThumbnailGeneratorTest, NoThumbnailForIncognitoTab) { 55 TEST_F(ChromeActivityItemThumbnailGeneratorTest, NoThumbnailForIncognitoTab) {
53 SetBrowserStateOnTab(true); 56 SetBrowserStateOnTab(true);
54 CGSize size = CGSizeMake(50, 50); 57 CGSize size = CGSizeMake(50, 50);
55 ThumbnailGeneratorBlock generatorBlock = 58 ThumbnailGeneratorBlock generatorBlock =
56 activity_services::ThumbnailGeneratorForTab(tab_); 59 activity_services::ThumbnailGeneratorForTab(tab_);
57 EXPECT_TRUE(generatorBlock); 60 EXPECT_TRUE(generatorBlock);
58 UIImage* thumbnail = generatorBlock(size); 61 UIImage* thumbnail = generatorBlock(size);
59 EXPECT_FALSE(thumbnail); 62 EXPECT_FALSE(thumbnail);
60 } 63 }
61 64
62 } // namespace 65 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/activity_services/activity_type_util_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698