Don't send offline status before the host has started.
[chromium-blink-merge.git] / url / gurl_test_main.cc
blobd35e5d4df6010642ed672576890a172ad3ca5bb3
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.
5 #include "build/build_config.h"
7 #if defined(OS_WIN)
8 #include <windows.h>
9 #endif
11 #include <string>
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/icu/source/common/unicode/putil.h"
15 #include "third_party/icu/source/common/unicode/udata.h"
17 #define ICU_UTIL_DATA_SHARED 1
18 #define ICU_UTIL_DATA_STATIC 2
20 #ifndef ICU_UTIL_DATA_IMPL
22 #if defined(OS_WIN)
23 #define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_SHARED
24 #elif defined(OS_MACOSX)
25 #define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_STATIC
26 #elif defined(OS_LINUX)
27 #define ICU_UTIL_DATA_IMPL ICU_UTIL_DATA_FILE
28 #endif
30 #endif // ICU_UTIL_DATA_IMPL
32 #if defined(OS_WIN)
33 #define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat"
34 #define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt" U_ICU_VERSION_SHORT ".dll"
35 #endif
37 bool InitializeICU() {
38 #if (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED)
39 // We expect to find the ICU data module alongside the current module.
40 // Because the module name is ASCII-only, "A" API should be safe.
41 // Chrome's copy of ICU dropped a version number XX from icudt dll,
42 // but 3rd-party embedders may need it. So, we try both.
43 HMODULE module = LoadLibraryA("icudt.dll");
44 if (!module) {
45 module = LoadLibraryA(ICU_UTIL_DATA_SHARED_MODULE_NAME);
46 if (!module)
47 return false;
50 FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL);
51 if (!addr)
52 return false;
54 UErrorCode err = U_ZERO_ERROR;
55 udata_setCommonData(reinterpret_cast<void*>(addr), &err);
56 return err == U_ZERO_ERROR;
57 #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC)
58 // Mac bundles the ICU data in.
59 return true;
60 #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE)
61 // We expect to find the ICU data module alongside the current module.
62 u_setDataDirectory(".");
63 // Only look for the packaged data file;
64 // the default behavior is to look for individual files.
65 UErrorCode err = U_ZERO_ERROR;
66 udata_setFileAccess(UDATA_ONLY_PACKAGES, &err);
67 return err == U_ZERO_ERROR;
68 #endif
71 int main(int argc, char **argv) {
72 ::testing::InitGoogleTest(&argc, argv);
74 InitializeICU();
76 return RUN_ALL_TESTS();