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/storekit_launcher.h" | 12 #import "ios/chrome/browser/storekit_launcher.h" |
14 #include "ios/web/public/test/test_web_thread.h" | 13 #include "ios/web/public/test/test_web_thread.h" |
15 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
16 #include "net/http/http_response_headers.h" | 15 #include "net/http/http_response_headers.h" |
17 #include "net/url_request/test_url_fetcher_factory.h" | 16 #include "net/url_request/test_url_fetcher_factory.h" |
18 #include "net/url_request/url_fetcher_delegate.h" | 17 #include "net/url_request/url_fetcher_delegate.h" |
19 #include "net/url_request/url_request_test_util.h" | 18 #include "net/url_request/url_request_test_util.h" |
20 #include "testing/gtest_mac.h" | 19 #include "testing/gtest_mac.h" |
21 #include "testing/platform_test.h" | 20 #include "testing/platform_test.h" |
22 | 21 |
22 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
23 #error "This file requires ARC support." | |
24 #endif | |
25 | |
23 using net::HttpResponseHeaders; | 26 using net::HttpResponseHeaders; |
24 using net::URLRequestStatus; | 27 using net::URLRequestStatus; |
25 | 28 |
26 @interface DownloadManagerController (ExposedForTesting) | 29 @interface DownloadManagerController (ExposedForTesting) |
27 - (UIView*)documentContainer; | 30 - (UIView*)documentContainer; |
28 - (UIView*)progressBar; | 31 - (UIView*)progressBar; |
29 - (UIImageView*)documentIcon; | 32 - (UIImageView*)documentIcon; |
30 - (UIImageView*)foldIcon; | 33 - (UIImageView*)foldIcon; |
31 - (UILabel*)timeLeftLabel; | 34 - (UILabel*)timeLeftLabel; |
32 - (UILabel*)fileTypeLabel; | 35 - (UILabel*)fileTypeLabel; |
(...skipping 28 matching lines...) Expand all Loading... | |
61 | 64 |
62 protected: | 65 protected: |
63 void SetUp() override { | 66 void SetUp() override { |
64 PlatformTest::SetUp(); | 67 PlatformTest::SetUp(); |
65 | 68 |
66 _request_context_getter = | 69 _request_context_getter = |
67 new net::TestURLRequestContextGetter(_message_loop.task_runner()); | 70 new net::TestURLRequestContextGetter(_message_loop.task_runner()); |
68 | 71 |
69 _fetcher_factory.reset(new net::TestURLFetcherFactory()); | 72 _fetcher_factory.reset(new net::TestURLFetcherFactory()); |
70 | 73 |
71 _store_kit_launcher.reset([[TestStoreKitLauncher alloc] init]); | 74 _store_kit_launcher = [[TestStoreKitLauncher alloc] init]; |
72 | 75 |
73 _controller.reset([[DownloadManagerController alloc] | 76 _controller = [[DownloadManagerController alloc] |
74 initWithURL:kTestURL | 77 initWithURL:kTestURL |
75 requestContextGetter:_request_context_getter.get() | 78 requestContextGetter:_request_context_getter.get() |
76 storeKitLauncher:_store_kit_launcher.get()]); | 79 storeKitLauncher:_store_kit_launcher]; |
77 } | 80 } |
78 | 81 |
79 base::MessageLoop _message_loop; | 82 base::MessageLoop _message_loop; |
80 web::TestWebThread _ui_thread; | 83 web::TestWebThread _ui_thread; |
81 base::scoped_nsobject<TestStoreKitLauncher> _store_kit_launcher; | 84 TestStoreKitLauncher* _store_kit_launcher; |
82 scoped_refptr<net::TestURLRequestContextGetter> _request_context_getter; | 85 scoped_refptr<net::TestURLRequestContextGetter> _request_context_getter; |
83 std::unique_ptr<net::TestURLFetcherFactory> _fetcher_factory; | 86 std::unique_ptr<net::TestURLFetcherFactory> _fetcher_factory; |
84 base::scoped_nsobject<DownloadManagerController> _controller; | 87 DownloadManagerController* _controller; |
noyau (Ping after 24h)
2017/02/03 12:57:48
Same here, I'm becoming more uncomfortable changin
stkhapugin
2017/02/03 13:05:57
This is a private unit test-only class in an imple
noyau (Ping after 24h)
2017/03/17 13:26:01
Sorry for the delay. These need strong as discusse
stkhapugin
2017/04/11 15:55:15
Done.
| |
85 }; | 88 }; |
86 | 89 |
87 TEST_F(DownloadManagerControllerTest, TestXibViewConnections) { | 90 TEST_F(DownloadManagerControllerTest, TestXibViewConnections) { |
88 EXPECT_TRUE([_controller documentContainer]); | 91 EXPECT_TRUE([_controller documentContainer]); |
89 EXPECT_TRUE([_controller progressBar]); | 92 EXPECT_TRUE([_controller progressBar]); |
90 EXPECT_TRUE([_controller documentIcon]); | 93 EXPECT_TRUE([_controller documentIcon]); |
91 EXPECT_TRUE([_controller foldIcon]); | 94 EXPECT_TRUE([_controller foldIcon]); |
92 EXPECT_TRUE([_controller timeLeftLabel]); | 95 EXPECT_TRUE([_controller timeLeftLabel]); |
93 EXPECT_TRUE([_controller fileTypeLabel]); | 96 EXPECT_TRUE([_controller fileTypeLabel]); |
94 EXPECT_TRUE([_controller fileNameLabel]); | 97 EXPECT_TRUE([_controller fileNameLabel]); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 EXPECT_FALSE( | 149 EXPECT_FALSE( |
147 [[UIApplication sharedApplication] isNetworkActivityIndicatorVisible]); | 150 [[UIApplication sharedApplication] isNetworkActivityIndicatorVisible]); |
148 | 151 |
149 EXPECT_TRUE([_controller fileTypeLabel].hidden); | 152 EXPECT_TRUE([_controller fileTypeLabel].hidden); |
150 EXPECT_FALSE([_controller downloadButton].hidden); | 153 EXPECT_FALSE([_controller downloadButton].hidden); |
151 EXPECT_FALSE([_controller errorIcon].hidden); | 154 EXPECT_FALSE([_controller errorIcon].hidden); |
152 EXPECT_FALSE([_controller errorOrSizeLabel].hidden); | 155 EXPECT_FALSE([_controller errorOrSizeLabel].hidden); |
153 } | 156 } |
154 | 157 |
155 } // namespace | 158 } // namespace |
OLD | NEW |