Index: ios/chrome/browser/ui/static_content/static_html_native_content_unittest.mm |
diff --git a/ios/chrome/browser/ui/static_content/static_html_native_content_unittest.mm b/ios/chrome/browser/ui/static_content/static_html_native_content_unittest.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ffa3fda1734173be44ce0418565d2a2ab2360333 |
--- /dev/null |
+++ b/ios/chrome/browser/ui/static_content/static_html_native_content_unittest.mm |
@@ -0,0 +1,74 @@ |
+// 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/static_content/static_html_native_content.h" |
+ |
+#include <memory> |
+ |
+#include "base/mac/scoped_nsobject.h" |
+#include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
+#include "ios/chrome/browser/ui/static_content/static_html_view_controller.h" |
+#import "ios/chrome/browser/ui/url_loader.h" |
+#include "ios/web/public/test/test_web_thread_bundle.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+#include "testing/gtest_mac.h" |
+#include "testing/platform_test.h" |
+#import "third_party/ocmock/OCMock/OCMock.h" |
+#include "third_party/ocmock/gtest_support.h" |
+ |
+@interface StaticHtmlNativeContentTestGenerator : NSObject<HtmlGenerator> |
+@end |
+ |
+@implementation StaticHtmlNativeContentTestGenerator |
+- (void)generateHtml:(HtmlCallback)callback { |
+ callback(@"<html><body><p>Hello, World!</p></body></html>"); |
+} |
+@end |
+ |
+namespace { |
+ |
+class StaticHtmlNativeContentTest : public PlatformTest { |
+ protected: |
+ void SetUp() override { |
+ PlatformTest::SetUp(); |
+ TestChromeBrowserState::Builder test_cbs_builder; |
+ chrome_browser_state_ = test_cbs_builder.Build(); |
+ } |
+ web::TestWebThreadBundle thread_bundle_; |
+ std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; |
+}; |
+ |
+TEST_F(StaticHtmlNativeContentTest, BasicResourceTest) { |
+ GURL url("chrome://foo"); |
+ id<UrlLoader> loader = [OCMockObject mockForProtocol:@protocol(UrlLoader)]; |
+ base::scoped_nsobject<StaticHtmlNativeContent> content( |
+ [[StaticHtmlNativeContent alloc] |
+ initWithResourcePathResource:@"about_credits.html" |
+ loader:loader |
+ browserState:chrome_browser_state_.get() |
+ url:url]); |
+ |
+ ASSERT_EQ(url, [content url]); |
+ ASSERT_OCMOCK_VERIFY((OCMockObject*)loader); |
+} |
+ |
+TEST_F(StaticHtmlNativeContentTest, BasicInitTest) { |
+ GURL url("chrome://foo"); |
+ id<UrlLoader> loader = [OCMockObject mockForProtocol:@protocol(UrlLoader)]; |
+ base::scoped_nsobject<StaticHtmlNativeContentTestGenerator> generator( |
+ [[StaticHtmlNativeContentTestGenerator alloc] init]); |
+ |
+ base::scoped_nsobject<StaticHtmlViewController> viewController( |
+ [[StaticHtmlViewController alloc] |
+ initWithGenerator:generator |
+ browserState:chrome_browser_state_.get()]); |
+ base::scoped_nsobject<StaticHtmlNativeContent> content( |
+ [[StaticHtmlNativeContent alloc] initWithLoader:loader |
+ staticHTMLViewController:viewController |
+ URL:url]); |
+ ASSERT_EQ(url, [content url]); |
+ ASSERT_OCMOCK_VERIFY((OCMockObject*)loader); |
+} |
+ |
+} // namespace |