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

Side by Side Diff: ios/chrome/browser/ui/chrome_web_view_factory_unittest.mm

Issue 2936833002: [ObjC ARC] Converts ios/chrome/browser/ui:unit_tests to ARC. (Closed)
Patch Set: Fix bad ARC guard. Created 3 years, 6 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/chrome_web_view_factory.h" 5 #import "ios/chrome/browser/ui/chrome_web_view_factory.h"
6 6
7 #include "base/mac/scoped_nsobject.h"
8 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
9 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 9 #include "base/run_loop.h"
11 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_isolated_co ntext.h" 10 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_isolated_co ntext.h"
12 #import "ios/chrome/browser/web/chrome_web_client.h" 11 #import "ios/chrome/browser/web/chrome_web_client.h"
13 #include "ios/web/net/request_group_util.h" 12 #include "ios/web/net/request_group_util.h"
14 #include "ios/web/net/request_tracker_impl.h" 13 #include "ios/web/net/request_tracker_impl.h"
15 #include "ios/web/public/test/scoped_testing_web_client.h" 14 #include "ios/web/public/test/scoped_testing_web_client.h"
16 #include "ios/web/public/test/test_web_thread.h" 15 #include "ios/web/public/test/test_web_thread.h"
17 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/gtest_mac.h" 17 #include "testing/gtest_mac.h"
19 #include "testing/platform_test.h" 18 #include "testing/platform_test.h"
20 #import "third_party/ocmock/OCMock/OCMock.h" 19 #import "third_party/ocmock/OCMock/OCMock.h"
21 #import "third_party/ocmock/gtest_support.h" 20 #import "third_party/ocmock/gtest_support.h"
22 21
22 #if !defined(__has_feature) || !__has_feature(objc_arc)
23 #error "This file requires ARC support."
24 #endif
25
23 using web::RequestTrackerImpl; 26 using web::RequestTrackerImpl;
24 27
25 namespace { 28 namespace {
26 29
27 class ChromeWebViewFactoryTest : public PlatformTest { 30 class ChromeWebViewFactoryTest : public PlatformTest {
28 public: 31 public:
29 ChromeWebViewFactoryTest() 32 ChromeWebViewFactoryTest()
30 : ui_thread_(web::WebThread::UI, &message_loop_), 33 : ui_thread_(web::WebThread::UI, &message_loop_),
31 io_thread_(web::WebThread::IO, &message_loop_), 34 io_thread_(web::WebThread::IO, &message_loop_),
32 web_client_(base::MakeUnique<ChromeWebClient>()) {} 35 web_client_(base::MakeUnique<ChromeWebClient>()) {}
33 36
34 protected: 37 protected:
35 base::MessageLoop message_loop_; 38 base::MessageLoop message_loop_;
36 web::TestWebThread ui_thread_; 39 web::TestWebThread ui_thread_;
37 web::TestWebThread io_thread_; 40 web::TestWebThread io_thread_;
38 web::ScopedTestingWebClient web_client_; 41 web::ScopedTestingWebClient web_client_;
39 TestChromeBrowserStateWithIsolatedContext chrome_browser_state_; 42 TestChromeBrowserStateWithIsolatedContext chrome_browser_state_;
40 43
41 private: 44 private:
42 DISALLOW_COPY_AND_ASSIGN(ChromeWebViewFactoryTest); 45 DISALLOW_COPY_AND_ASSIGN(ChromeWebViewFactoryTest);
43 }; 46 };
44 47
45 TEST_F(ChromeWebViewFactoryTest, TestTrackerForExternal) { 48 TEST_F(ChromeWebViewFactoryTest, TestTrackerForExternal) {
46 [ChromeWebViewFactory setBrowserStateToUseForExternal:&chrome_browser_state_]; 49 [ChromeWebViewFactory setBrowserStateToUseForExternal:&chrome_browser_state_];
47 base::scoped_nsobject<UIWebView> webView([ChromeWebViewFactory 50 #pragma clang diagnostic push
48 newExternalWebView:chrome_browser_state_.SharingService()]); 51 #pragma clang diagnostic ignored "-Wunused-variable"
52 UIWebView* webView = [ChromeWebViewFactory
53 newExternalWebView:chrome_browser_state_.SharingService()];
54 #pragma clang diagnostic pop
49 // Check that the tracker is registered 55 // Check that the tracker is registered
50 RequestTrackerImpl* tracker = RequestTrackerImpl::GetTrackerForRequestGroupID( 56 RequestTrackerImpl* tracker = RequestTrackerImpl::GetTrackerForRequestGroupID(
51 ChromeWebView::kExternalRequestGroupID); 57 ChromeWebView::kExternalRequestGroupID);
52 EXPECT_TRUE(tracker) << "Tracker not registered."; 58 EXPECT_TRUE(tracker) << "Tracker not registered.";
53 // External should use the request context for the sharing service, and not 59 // External should use the request context for the sharing service, and not
54 // the main one. 60 // the main one.
55 net::URLRequestContextGetter* expected_getter = [ChromeWebViewFactory 61 net::URLRequestContextGetter* expected_getter = [ChromeWebViewFactory
56 requestContextForExternalService:chrome_browser_state_.SharingService()]; 62 requestContextForExternalService:chrome_browser_state_.SharingService()];
57 EXPECT_EQ(expected_getter->GetURLRequestContext(), 63 EXPECT_EQ(expected_getter->GetURLRequestContext(),
58 tracker->GetRequestContext()); 64 tracker->GetRequestContext());
59 EXPECT_FALSE(chrome_browser_state_.MainContextCalled()); 65 EXPECT_FALSE(chrome_browser_state_.MainContextCalled());
60 // Unregister the tracker. 66 // Unregister the tracker.
61 [ChromeWebViewFactory externalSessionFinished]; 67 [ChromeWebViewFactory externalSessionFinished];
62 base::RunLoop().RunUntilIdle(); 68 base::RunLoop().RunUntilIdle();
63 EXPECT_FALSE(RequestTrackerImpl::GetTrackerForRequestGroupID( 69 EXPECT_FALSE(RequestTrackerImpl::GetTrackerForRequestGroupID(
64 ChromeWebView::kExternalRequestGroupID)); 70 ChromeWebView::kExternalRequestGroupID));
65 [ChromeWebViewFactory setBrowserStateToUseForExternal:nullptr]; 71 [ChromeWebViewFactory setBrowserStateToUseForExternal:nullptr];
66 } 72 }
67 73
68 } // namespace 74 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/browser_view_controller_unittest.mm ('k') | ios/chrome/browser/ui/file_locations_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698