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

Side by Side Diff: ios/chrome/browser/ui/static_content/static_html_native_content_unittest.mm

Issue 2691573002: [ObjC ARC] Converts ios/chrome/browser/ui/static_content:unit_tests to ARC. (Closed)
Patch Set: format 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/static_content/static_html_native_content.h" 5 #import "ios/chrome/browser/ui/static_content/static_html_native_content.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/mac/scoped_nsobject.h"
10 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" 9 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
11 #include "ios/chrome/browser/ui/static_content/static_html_view_controller.h" 10 #include "ios/chrome/browser/ui/static_content/static_html_view_controller.h"
12 #import "ios/chrome/browser/ui/url_loader.h" 11 #import "ios/chrome/browser/ui/url_loader.h"
13 #include "ios/web/public/test/test_web_thread_bundle.h" 12 #include "ios/web/public/test/test_web_thread_bundle.h"
14 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
15 #include "testing/gtest_mac.h" 14 #include "testing/gtest_mac.h"
16 #include "testing/platform_test.h" 15 #include "testing/platform_test.h"
17 #import "third_party/ocmock/OCMock/OCMock.h" 16 #import "third_party/ocmock/OCMock/OCMock.h"
18 #include "third_party/ocmock/gtest_support.h" 17 #include "third_party/ocmock/gtest_support.h"
19 18
19 #if !defined(__has_feature) || !__has_feature(objc_arc)
20 #error "This file requires ARC support."
21 #endif
22
20 @interface StaticHtmlNativeContentTestGenerator : NSObject<HtmlGenerator> 23 @interface StaticHtmlNativeContentTestGenerator : NSObject<HtmlGenerator>
21 @end 24 @end
22 25
23 @implementation StaticHtmlNativeContentTestGenerator 26 @implementation StaticHtmlNativeContentTestGenerator
24 - (void)generateHtml:(HtmlCallback)callback { 27 - (void)generateHtml:(HtmlCallback)callback {
25 callback(@"<html><body><p>Hello, World!</p></body></html>"); 28 callback(@"<html><body><p>Hello, World!</p></body></html>");
26 } 29 }
27 @end 30 @end
28 31
29 namespace { 32 namespace {
30 33
31 class StaticHtmlNativeContentTest : public PlatformTest { 34 class StaticHtmlNativeContentTest : public PlatformTest {
32 protected: 35 protected:
33 void SetUp() override { 36 void SetUp() override {
34 PlatformTest::SetUp(); 37 PlatformTest::SetUp();
35 TestChromeBrowserState::Builder test_cbs_builder; 38 TestChromeBrowserState::Builder test_cbs_builder;
36 chrome_browser_state_ = test_cbs_builder.Build(); 39 chrome_browser_state_ = test_cbs_builder.Build();
37 } 40 }
38 web::TestWebThreadBundle thread_bundle_; 41 web::TestWebThreadBundle thread_bundle_;
39 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; 42 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
40 }; 43 };
41 44
42 TEST_F(StaticHtmlNativeContentTest, BasicResourceTest) { 45 TEST_F(StaticHtmlNativeContentTest, BasicResourceTest) {
43 GURL url("chrome://foo"); 46 GURL url("chrome://foo");
44 id<UrlLoader> loader = [OCMockObject mockForProtocol:@protocol(UrlLoader)]; 47 id<UrlLoader> loader = [OCMockObject mockForProtocol:@protocol(UrlLoader)];
45 base::scoped_nsobject<StaticHtmlNativeContent> content( 48 StaticHtmlNativeContent* content = [[StaticHtmlNativeContent alloc]
46 [[StaticHtmlNativeContent alloc] 49 initWithResourcePathResource:@"about_credits.html"
47 initWithResourcePathResource:@"about_credits.html" 50 loader:loader
48 loader:loader 51 browserState:chrome_browser_state_.get()
49 browserState:chrome_browser_state_.get() 52 url:url];
50 url:url]);
51 53
52 ASSERT_EQ(url, [content url]); 54 ASSERT_EQ(url, [content url]);
53 ASSERT_OCMOCK_VERIFY((OCMockObject*)loader); 55 ASSERT_OCMOCK_VERIFY((OCMockObject*)loader);
54 } 56 }
55 57
56 TEST_F(StaticHtmlNativeContentTest, BasicInitTest) { 58 TEST_F(StaticHtmlNativeContentTest, BasicInitTest) {
57 GURL url("chrome://foo"); 59 GURL url("chrome://foo");
58 id<UrlLoader> loader = [OCMockObject mockForProtocol:@protocol(UrlLoader)]; 60 id<UrlLoader> loader = [OCMockObject mockForProtocol:@protocol(UrlLoader)];
59 base::scoped_nsobject<StaticHtmlNativeContentTestGenerator> generator( 61 StaticHtmlNativeContentTestGenerator* generator =
60 [[StaticHtmlNativeContentTestGenerator alloc] init]); 62 [[StaticHtmlNativeContentTestGenerator alloc] init];
61 63
62 base::scoped_nsobject<StaticHtmlViewController> viewController( 64 StaticHtmlViewController* viewController = [[StaticHtmlViewController alloc]
63 [[StaticHtmlViewController alloc] 65 initWithGenerator:generator
64 initWithGenerator:generator 66 browserState:chrome_browser_state_.get()];
65 browserState:chrome_browser_state_.get()]); 67 StaticHtmlNativeContent* content =
66 base::scoped_nsobject<StaticHtmlNativeContent> content(
67 [[StaticHtmlNativeContent alloc] initWithLoader:loader 68 [[StaticHtmlNativeContent alloc] initWithLoader:loader
68 staticHTMLViewController:viewController 69 staticHTMLViewController:viewController
69 URL:url]); 70 URL:url];
70 ASSERT_EQ(url, [content url]); 71 ASSERT_EQ(url, [content url]);
71 ASSERT_OCMOCK_VERIFY((OCMockObject*)loader); 72 ASSERT_OCMOCK_VERIFY((OCMockObject*)loader);
72 } 73 }
73 74
74 } // namespace 75 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698