Commit dc55754c authored by droger's avatar droger Committed by Commit bot

Upstream utilities for iOS

Review URL: https://codereview.chromium.org/887043002

Cr-Commit-Position: refs/heads/master@{#314326}
parent 434520c8
// Copyright 2014 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.
#include "ios/chrome/browser/arch_util.h"
namespace arch_util {
// const char[] can be initialized only with literal.
#define _ARM_ARCH "arm"
#define _ARM_64_ARCH "arm64"
const char kARMArch[] = _ARM_ARCH;
const char kARM64Arch[] = _ARM_64_ARCH;
#if defined(__LP64__)
const char kCurrentArch[] = _ARM_64_ARCH;
#else
const char kCurrentArch[] = _ARM_ARCH;
#endif
} // namespace arch_util
// Copyright 2014 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.
#ifndef IOS_CHROME_BROWSER_ARCH_UTIL_H_
#define IOS_CHROME_BROWSER_ARCH_UTIL_H_
namespace arch_util {
// Architecture of the currently running binary. Depends on the combination of
// app binary archs and device's arch. e.g. for arm7/arm64 fat binary running
// on 64-bit processor the value will be "arm64", but for the same fat binary
// running on 32-bit processor the value will be "arm".
extern const char kCurrentArch[];
// Constant for 32-bit ARM architecture.
extern const char kARMArch[];
// Constant for 64-bit ARM architecture.
extern const char kARM64Arch[];
} // namespace arch_util
#endif // IOS_CHROME_BROWSER_ARCH_UTIL_H_
// 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.
#include "ios/chrome/browser/chrome_url_constants.h"
const char kChromeUIExternalFileHost[] = "external-file";
const char kChromeUIOmahaHost[] = "omaha";
const char kChromeUISetUpForTestingHost[] = "setupfortesting";
// 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.
// Contains constants for known URLs and portions thereof.
#ifndef IOS_CHROME_BROWSER_CHROME_URL_CONSTANTS_H_
#define IOS_CHROME_BROWSER_CHROME_URL_CONSTANTS_H_
// URL components for Chrome on iOS.
extern const char kChromeUIExternalFileHost[];
extern const char kChromeUIOmahaHost[];
extern const char kChromeUISetUpForTestingHost[];
#endif // IOS_CHROME_BROWSER_CHROME_URL_CONSTANTS_H_
...@@ -10,9 +10,6 @@ ...@@ -10,9 +10,6 @@
#include "url/gurl.h" #include "url/gurl.h"
TEST(TranslateServiceIOSTest, CheckTranslatableURL) { TEST(TranslateServiceIOSTest, CheckTranslatableURL) {
// TODO(droger): Remove this once http://crbug.com/437332 is fixed.
ios::TestChromeProviderInitializer test_chrome_provider_initializer;
GURL empty_url = GURL(std::string()); GURL empty_url = GURL(std::string());
EXPECT_FALSE(TranslateServiceIOS::IsTranslatableURL(empty_url)); EXPECT_FALSE(TranslateServiceIOS::IsTranslatableURL(empty_url));
......
...@@ -48,8 +48,12 @@ ...@@ -48,8 +48,12 @@
'browser/application_context.h', 'browser/application_context.h',
'browser/application_context_impl.cc', 'browser/application_context_impl.cc',
'browser/application_context_impl.h', 'browser/application_context_impl.h',
'browser/arch_util.cc',
'browser/arch_util.h',
'browser/browser_state/browser_state_otr_helper.cc', 'browser/browser_state/browser_state_otr_helper.cc',
'browser/browser_state/browser_state_otr_helper.h', 'browser/browser_state/browser_state_otr_helper.h',
'browser/chrome_url_constants.cc',
'browser/chrome_url_constants.h',
'browser/infobars/confirm_infobar_controller.h', 'browser/infobars/confirm_infobar_controller.h',
'browser/infobars/confirm_infobar_controller.mm', 'browser/infobars/confirm_infobar_controller.mm',
'browser/infobars/infobar.h', 'browser/infobars/infobar.h',
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
'type': '<(gtest_target_type)', 'type': '<(gtest_target_type)',
'dependencies': [ 'dependencies': [
'../../base/base.gyp:base', '../../base/base.gyp:base',
'../../base/base.gyp:run_all_unittests',
'../../base/base.gyp:test_support_base', '../../base/base.gyp:test_support_base',
'../../net/net.gyp:net_test_support', '../../net/net.gyp:net_test_support',
'../../testing/gmock.gyp:gmock', '../../testing/gmock.gyp:gmock',
...@@ -21,6 +20,7 @@ ...@@ -21,6 +20,7 @@
'../web/ios_web.gyp:ios_web', '../web/ios_web.gyp:ios_web',
'../web/ios_web.gyp:test_support_ios_web', '../web/ios_web.gyp:test_support_ios_web',
'ios_chrome.gyp:ios_chrome_browser', 'ios_chrome.gyp:ios_chrome_browser',
'ios_chrome_test_support',
], ],
'sources': [ 'sources': [
'browser/net/image_fetcher_unittest.mm', 'browser/net/image_fetcher_unittest.mm',
...@@ -35,10 +35,14 @@ ...@@ -35,10 +35,14 @@
'type': 'static_library', 'type': 'static_library',
'dependencies': [ 'dependencies': [
'../../base/base.gyp:base', '../../base/base.gyp:base',
'../../testing/gtest.gyp:gtest',
'../provider/ios_provider_chrome.gyp:ios_provider_chrome_browser', '../provider/ios_provider_chrome.gyp:ios_provider_chrome_browser',
'ios_chrome.gyp:ios_chrome_browser', 'ios_chrome.gyp:ios_chrome_browser',
], ],
'sources': [ 'sources': [
'test/ios_chrome_unit_test_suite.cc',
'test/ios_chrome_unit_test_suite.h',
'test/run_all_unittests.cc',
'test/testing_application_context.cc', 'test/testing_application_context.cc',
'test/testing_application_context.h', 'test/testing_application_context.h',
], ],
......
// Copyright 2015 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.
#include "ios/chrome/test/ios_chrome_unit_test_suite.h"
#include "ios/public/test/test_chrome_browser_provider.h"
#include "ios/public/test/test_chrome_provider_initializer.h"
#include "ios/web/public/web_client.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_paths.h"
#include "url/url_util.h"
namespace {
class IOSChromeUnitTestSuiteInitializer
: public testing::EmptyTestEventListener {
public:
IOSChromeUnitTestSuiteInitializer() {}
~IOSChromeUnitTestSuiteInitializer() override {}
void OnTestStart(const testing::TestInfo& test_info) override {
web_client_.reset(new web::WebClient());
web::SetWebClient(web_client_.get());
test_ios_chrome_provider_initializer_.reset(
new ios::TestChromeProviderInitializer());
}
void OnTestEnd(const testing::TestInfo& test_info) override {
web_client_.reset();
web::SetWebClient(NULL);
test_ios_chrome_provider_initializer_.reset();
}
private:
scoped_ptr<web::WebClient> web_client_;
scoped_ptr<ios::TestChromeProviderInitializer>
test_ios_chrome_provider_initializer_;
DISALLOW_COPY_AND_ASSIGN(IOSChromeUnitTestSuiteInitializer);
};
} // namespace
IOSChromeUnitTestSuite::IOSChromeUnitTestSuite(int argc, char** argv)
: base::TestSuite(argc, argv) {
}
IOSChromeUnitTestSuite::~IOSChromeUnitTestSuite() {
}
void IOSChromeUnitTestSuite::Initialize() {
// Add an additional listener to do the extra initialization for unit tests.
// It will be started before the base class listeners and ended after the
// base class listeners.
testing::TestEventListeners& listeners =
testing::UnitTest::GetInstance()->listeners();
listeners.Append(new IOSChromeUnitTestSuiteInitializer);
ui::RegisterPathProvider();
{
ios::TestChromeBrowserProvider provider;
url::AddStandardScheme(provider.GetChromeUIScheme());
}
base::TestSuite::Initialize();
}
// Copyright 2015 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.
#ifndef IOS_CHROME_TEST_IOS_CHROME_UNIT_TEST_SUITE_H_
#define IOS_CHROME_TEST_IOS_CHROME_UNIT_TEST_SUITE_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/test/test_suite.h"
// Test suite for unit tests.
class IOSChromeUnitTestSuite : public base::TestSuite {
public:
IOSChromeUnitTestSuite(int argc, char** argv);
~IOSChromeUnitTestSuite() override;
// base::TestSuite overrides:
void Initialize() override;
private:
DISALLOW_COPY_AND_ASSIGN(IOSChromeUnitTestSuite);
};
#endif // IOS_CHROME_TEST_IOS_CHROME_UNIT_TEST_SUITE_H_
// Copyright 2015 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.
#include "base/bind.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "ios/chrome/test/ios_chrome_unit_test_suite.h"
int main(int argc, char** argv) {
IOSChromeUnitTestSuite test_suite(argc, argv);
return base::LaunchUnitTests(
argc, argv,
base::Bind(&IOSChromeUnitTestSuite::Run, base::Unretained(&test_suite)));
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment