OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/downloads/download_manager_controller.h" | 5 #import "ios/chrome/browser/ui/downloads/download_manager_controller.h" |
6 | 6 |
7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #import "base/mac/scoped_nsobject.h" | |
12 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
13 #import "ios/chrome/browser/store_kit/store_kit_launcher.h" | 12 #import "ios/chrome/browser/store_kit/store_kit_launcher.h" |
14 #import "ios/chrome/browser/store_kit/store_kit_tab_helper.h" | 13 #import "ios/chrome/browser/store_kit/store_kit_tab_helper.h" |
15 #import "ios/chrome/browser/web/chrome_web_test.h" | 14 #import "ios/chrome/browser/web/chrome_web_test.h" |
16 #include "ios/web/public/test/test_web_thread.h" | 15 #include "ios/web/public/test/test_web_thread.h" |
17 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
18 #include "net/http/http_response_headers.h" | 17 #include "net/http/http_response_headers.h" |
19 #include "net/url_request/test_url_fetcher_factory.h" | 18 #include "net/url_request/test_url_fetcher_factory.h" |
20 #include "net/url_request/url_fetcher_delegate.h" | 19 #include "net/url_request/url_fetcher_delegate.h" |
21 #include "net/url_request/url_request_test_util.h" | 20 #include "net/url_request/url_request_test_util.h" |
22 #include "testing/gtest_mac.h" | 21 #include "testing/gtest_mac.h" |
23 #include "testing/platform_test.h" | 22 #include "testing/platform_test.h" |
24 #import "third_party/ocmock/OCMock/OCMock.h" | 23 #import "third_party/ocmock/OCMock/OCMock.h" |
25 | 24 |
| 25 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 26 #error "This file requires ARC support." |
| 27 #endif |
| 28 |
26 using net::HttpResponseHeaders; | 29 using net::HttpResponseHeaders; |
27 using net::URLRequestStatus; | 30 using net::URLRequestStatus; |
28 | 31 |
29 @interface DownloadManagerController (ExposedForTesting) | 32 @interface DownloadManagerController (ExposedForTesting) |
30 - (UIView*)documentContainer; | 33 - (UIView*)documentContainer; |
31 - (UIView*)progressBar; | 34 - (UIView*)progressBar; |
32 - (UIImageView*)documentIcon; | 35 - (UIImageView*)documentIcon; |
33 - (UIImageView*)foldIcon; | 36 - (UIImageView*)foldIcon; |
34 - (UILabel*)timeLeftLabel; | 37 - (UILabel*)timeLeftLabel; |
35 - (UILabel*)fileTypeLabel; | 38 - (UILabel*)fileTypeLabel; |
(...skipping 15 matching lines...) Expand all Loading... |
51 class DownloadManagerControllerTest : public ChromeWebTest { | 54 class DownloadManagerControllerTest : public ChromeWebTest { |
52 protected: | 55 protected: |
53 void SetUp() override { | 56 void SetUp() override { |
54 ChromeWebTest::SetUp(); | 57 ChromeWebTest::SetUp(); |
55 _fetcher_factory.reset(new net::TestURLFetcherFactory()); | 58 _fetcher_factory.reset(new net::TestURLFetcherFactory()); |
56 StoreKitTabHelper::CreateForWebState(web_state()); | 59 StoreKitTabHelper::CreateForWebState(web_state()); |
57 StoreKitTabHelper* helper = StoreKitTabHelper::FromWebState(web_state()); | 60 StoreKitTabHelper* helper = StoreKitTabHelper::FromWebState(web_state()); |
58 id mock_launcher = | 61 id mock_launcher = |
59 [OCMockObject niceMockForProtocol:@protocol(StoreKitLauncher)]; | 62 [OCMockObject niceMockForProtocol:@protocol(StoreKitLauncher)]; |
60 helper->SetLauncher(mock_launcher); | 63 helper->SetLauncher(mock_launcher); |
61 _controller.reset([[DownloadManagerController alloc] | 64 _controller = |
62 initWithWebState:web_state() | 65 [[DownloadManagerController alloc] initWithWebState:web_state() |
63 downloadURL:kTestURL]); | 66 downloadURL:kTestURL]; |
64 } | 67 } |
65 | |
66 std::unique_ptr<net::TestURLFetcherFactory> _fetcher_factory; | 68 std::unique_ptr<net::TestURLFetcherFactory> _fetcher_factory; |
67 base::scoped_nsobject<DownloadManagerController> _controller; | 69 __strong DownloadManagerController* _controller; |
68 }; | 70 }; |
69 | 71 |
70 TEST_F(DownloadManagerControllerTest, TestXibViewConnections) { | 72 TEST_F(DownloadManagerControllerTest, TestXibViewConnections) { |
71 EXPECT_TRUE([_controller documentContainer]); | 73 EXPECT_TRUE([_controller documentContainer]); |
72 EXPECT_TRUE([_controller progressBar]); | 74 EXPECT_TRUE([_controller progressBar]); |
73 EXPECT_TRUE([_controller documentIcon]); | 75 EXPECT_TRUE([_controller documentIcon]); |
74 EXPECT_TRUE([_controller foldIcon]); | 76 EXPECT_TRUE([_controller foldIcon]); |
75 EXPECT_TRUE([_controller timeLeftLabel]); | 77 EXPECT_TRUE([_controller timeLeftLabel]); |
76 EXPECT_TRUE([_controller fileTypeLabel]); | 78 EXPECT_TRUE([_controller fileTypeLabel]); |
77 EXPECT_TRUE([_controller fileNameLabel]); | 79 EXPECT_TRUE([_controller fileNameLabel]); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 EXPECT_FALSE( | 131 EXPECT_FALSE( |
130 [[UIApplication sharedApplication] isNetworkActivityIndicatorVisible]); | 132 [[UIApplication sharedApplication] isNetworkActivityIndicatorVisible]); |
131 | 133 |
132 EXPECT_TRUE([_controller fileTypeLabel].hidden); | 134 EXPECT_TRUE([_controller fileTypeLabel].hidden); |
133 EXPECT_FALSE([_controller downloadButton].hidden); | 135 EXPECT_FALSE([_controller downloadButton].hidden); |
134 EXPECT_FALSE([_controller errorIcon].hidden); | 136 EXPECT_FALSE([_controller errorIcon].hidden); |
135 EXPECT_FALSE([_controller errorOrSizeLabel].hidden); | 137 EXPECT_FALSE([_controller errorOrSizeLabel].hidden); |
136 } | 138 } |
137 | 139 |
138 } // namespace | 140 } // namespace |
OLD | NEW |