1// Copyright 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "ios/web/public/test/web_test_suite.h" 6 7#include "base/check.h" 8#include "base/memory/ptr_util.h" 9#include "base/path_service.h" 10#include "components/crash/core/common/objc_zombie.h" 11#include "ios/testing/verify_custom_webkit.h" 12#include "ios/web/public/navigation/url_schemes.h" 13#import "ios/web/public/test/fakes/test_web_client.h" 14#include "testing/gtest/include/gtest/gtest.h" 15#include "ui/base/resource/resource_bundle.h" 16 17#if !defined(__has_feature) || !__has_feature(objc_arc) 18#error "This file requires ARC support." 19#endif 20 21namespace web { 22 23WebTestSuite::WebTestSuite(int argc, char** argv) 24 : base::TestSuite(argc, argv), 25 web_client_(base::WrapUnique(new TestWebClient)) { 26 CHECK(IsCustomWebKitLoadedIfRequested()); 27#if TARGET_IPHONE_SIMULATOR 28 DCHECK(ObjcEvilDoers::ZombieEnable(true, 10000)); 29#endif 30} 31 32WebTestSuite::~WebTestSuite() { 33 // Verify again at the end of the test run, in case some frameworks were not 34 // yet loaded when the constructor ran. 35 CHECK(IsCustomWebKitLoadedIfRequested()); 36} 37 38void WebTestSuite::Initialize() { 39 base::TestSuite::Initialize(); 40 41 RegisterWebSchemes(); 42 43 // Force unittests to run using en-US so if testing string output will work 44 // regardless of the system language. 45 ui::ResourceBundle::InitSharedInstanceWithLocale( 46 "en-US", nullptr, ui::ResourceBundle::LOAD_COMMON_RESOURCES); 47 base::FilePath resources_pack_path; 48 base::PathService::Get(base::DIR_MODULE, &resources_pack_path); 49 resources_pack_path = 50 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); 51 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath( 52 resources_pack_path, ui::SCALE_FACTOR_NONE); 53} 54 55void WebTestSuite::Shutdown() { 56 ui::ResourceBundle::CleanupSharedInstance(); 57 base::TestSuite::Shutdown(); 58} 59 60} // namespace web 61