1 // Copyright (c) 2011 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 "chrome_frame/simple_resource_loader.h"
7 #include "base/files/file_path.h"
8 #include "base/win/windows_version.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/base/resource/data_pack.h"
12 TEST(SimpleResourceLoaderTest
, LoadLocaleDll
) {
13 std::vector
<std::wstring
> language_tags
;
14 base::FilePath locales_path
;
15 base::FilePath file_path
;
16 HMODULE dll_handle
= NULL
;
18 SimpleResourceLoader::DetermineLocalesDirectory(&locales_path
);
20 // Test valid language-region string:
21 language_tags
.clear();
22 language_tags
.push_back(L
"en-GB");
23 language_tags
.push_back(L
"en");
24 ui::DataPack
* data_pack
= NULL
;
26 std::wstring language
;
29 SimpleResourceLoader::LoadLocalePack(language_tags
, locales_path
,
30 &dll_handle
, &data_pack
,
32 if (NULL
!= dll_handle
) {
33 FreeLibrary(dll_handle
);
36 EXPECT_TRUE(data_pack
!= NULL
);
40 EXPECT_EQ(language
, L
"en-GB");
43 // Test valid language-region string for which we only have a language dll:
44 language_tags
.clear();
45 language_tags
.push_back(L
"fr-FR");
46 language_tags
.push_back(L
"fr");
48 SimpleResourceLoader::LoadLocalePack(language_tags
, locales_path
,
49 &dll_handle
, &data_pack
,
51 if (NULL
!= dll_handle
) {
52 FreeLibrary(dll_handle
);
55 EXPECT_TRUE(data_pack
!= NULL
);
59 EXPECT_EQ(language
, L
"fr");
62 // Test invalid language-region string, make sure fallback works:
63 language_tags
.clear();
64 language_tags
.push_back(L
"xx-XX");
65 language_tags
.push_back(L
"en-US");
67 SimpleResourceLoader::LoadLocalePack(language_tags
, locales_path
,
68 &dll_handle
, &data_pack
,
70 if (NULL
!= dll_handle
) {
71 FreeLibrary(dll_handle
);
75 EXPECT_TRUE(data_pack
!= NULL
);
79 EXPECT_EQ(language
, L
"en-US");
83 TEST(SimpleResourceLoaderTest
, InstanceTest
) {
84 SimpleResourceLoader
* loader
= SimpleResourceLoader::GetInstance();
86 ASSERT_TRUE(NULL
!= loader
);
87 ASSERT_TRUE(NULL
!= loader
->GetResourceModuleHandle());