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

Side by Side Diff: chrome_frame/test/simple_resource_loader_test.cc

Issue 7763006: Load both language packs and the resource dlls in ChromeFrame and look for localized strings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome_frame/simple_resource_loader.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome_frame/simple_resource_loader.h" 5 #include "chrome_frame/simple_resource_loader.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/win/windows_version.h" 8 #include "base/win/windows_version.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/base/resource/data_pack.h"
10 11
11 TEST(SimpleResourceLoaderTest, LoadLocaleDll) { 12 TEST(SimpleResourceLoaderTest, LoadLocaleDll) {
12 std::vector<std::wstring> language_tags; 13 std::vector<std::wstring> language_tags;
13 FilePath locales_path; 14 FilePath locales_path;
14 FilePath file_path; 15 FilePath file_path;
15 HMODULE dll_handle = NULL; 16 HMODULE dll_handle = NULL;
16 17
17 SimpleResourceLoader::DetermineLocalesDirectory(&locales_path); 18 SimpleResourceLoader::DetermineLocalesDirectory(&locales_path);
18 19
19 // Test valid language-region string: 20 // Test valid language-region string:
20 language_tags.clear(); 21 language_tags.clear();
21 language_tags.push_back(L"en-GB"); 22 language_tags.push_back(L"en-GB");
22 language_tags.push_back(L"en"); 23 language_tags.push_back(L"en");
24 ui::DataPack* data_pack = NULL;
25
26 std::wstring language;
27
23 EXPECT_TRUE( 28 EXPECT_TRUE(
24 SimpleResourceLoader::LoadLocaleDll(language_tags, locales_path, 29 SimpleResourceLoader::LoadLocalePack(language_tags, locales_path,
25 &dll_handle, &file_path)); 30 &dll_handle, &data_pack,
31 &language));
26 if (NULL != dll_handle) { 32 if (NULL != dll_handle) {
27 FreeLibrary(dll_handle); 33 FreeLibrary(dll_handle);
28 dll_handle = NULL; 34 dll_handle = NULL;
29 } 35 }
30 EXPECT_TRUE(file_path.BaseName() == FilePath(L"en-GB.dll")); 36 EXPECT_TRUE(data_pack != NULL);
37 delete data_pack;
38 data_pack = NULL;
39
40 EXPECT_EQ(language, L"en-GB");
41 language.clear();
31 42
32 // Test valid language-region string for which we only have a language dll: 43 // Test valid language-region string for which we only have a language dll:
33 language_tags.clear(); 44 language_tags.clear();
34 language_tags.push_back(L"fr-FR"); 45 language_tags.push_back(L"fr-FR");
35 language_tags.push_back(L"fr"); 46 language_tags.push_back(L"fr");
36 EXPECT_TRUE( 47 EXPECT_TRUE(
37 SimpleResourceLoader::LoadLocaleDll(language_tags, locales_path, 48 SimpleResourceLoader::LoadLocalePack(language_tags, locales_path,
38 &dll_handle, &file_path)); 49 &dll_handle, &data_pack,
50 &language));
39 if (NULL != dll_handle) { 51 if (NULL != dll_handle) {
40 FreeLibrary(dll_handle); 52 FreeLibrary(dll_handle);
41 dll_handle = NULL; 53 dll_handle = NULL;
42 } 54 }
43 EXPECT_TRUE(file_path.BaseName() == FilePath(L"fr.dll")); 55 EXPECT_TRUE(data_pack != NULL);
56 delete data_pack;
57 data_pack = NULL;
58
59 EXPECT_EQ(language, L"fr");
60 language.clear();
44 61
45 // Test invalid language-region string, make sure fallback works: 62 // Test invalid language-region string, make sure fallback works:
46 language_tags.clear(); 63 language_tags.clear();
47 language_tags.push_back(L"xx-XX"); 64 language_tags.push_back(L"xx-XX");
48 language_tags.push_back(L"en-US"); 65 language_tags.push_back(L"en-US");
49 EXPECT_TRUE( 66 EXPECT_TRUE(
50 SimpleResourceLoader::LoadLocaleDll(language_tags, locales_path, 67 SimpleResourceLoader::LoadLocalePack(language_tags, locales_path,
51 &dll_handle, &file_path)); 68 &dll_handle, &data_pack,
69 &language));
52 if (NULL != dll_handle) { 70 if (NULL != dll_handle) {
53 FreeLibrary(dll_handle); 71 FreeLibrary(dll_handle);
54 dll_handle = NULL; 72 dll_handle = NULL;
55 } 73 }
56 EXPECT_TRUE(file_path.BaseName() == FilePath(L"en-US.dll")); 74
75 EXPECT_TRUE(data_pack != NULL);
76 delete data_pack;
77 data_pack = NULL;
78
79 EXPECT_EQ(language, L"en-US");
80 language.clear();
57 } 81 }
58 82
59 TEST(SimpleResourceLoaderTest, InstanceTest) { 83 TEST(SimpleResourceLoaderTest, InstanceTest) {
60 SimpleResourceLoader* loader = SimpleResourceLoader::GetInstance(); 84 SimpleResourceLoader* loader = SimpleResourceLoader::GetInstance();
61 85
62 ASSERT_TRUE(NULL != loader); 86 ASSERT_TRUE(NULL != loader);
63 ASSERT_TRUE(NULL != loader->GetResourceModuleHandle()); 87 ASSERT_TRUE(NULL != loader->GetResourceModuleHandle());
64 } 88 }
OLDNEW
« no previous file with comments | « chrome_frame/simple_resource_loader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698