Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/DictionaryTest.cpp

Issue 11254007: Installation with registry keys
Patch Set: Created July 25, 2013, 9:57 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/shared/Utils.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/DictionaryTest.cpp
===================================================================
--- a/test/DictionaryTest.cpp
+++ b/test/DictionaryTest.cpp
@@ -43,6 +43,41 @@
}
}
+namespace
+{
+ // See http://blogs.msdn.com/b/oldnewthing/archive/2004/10/25/247180.aspx
+ EXTERN_C IMAGE_DOS_HEADER __ImageBase;
+}
+
+std::wstring GetDllDir()
+{
+ std::vector<WCHAR> path(MAX_PATH);
+ DWORD length = GetModuleFileNameW((HINSTANCE)&__ImageBase, &path[0], path.size());
+
+ while (length == path.size())
+ {
+ // Buffer too small, double buffer size
+ path.resize(path.size() * 2);
+ length = GetModuleFileNameW((HINSTANCE)&__ImageBase, &path[0], path.size());
+ }
+
+ try
+ {
+ if (length == 0)
+ throw std::runtime_error("Failed determining module path");
+
+ std::vector<WCHAR>::reverse_iterator it = std::find(path.rbegin(), path.rend(), L'\\');
+ if (it == path.rend())
+ throw std::runtime_error("Unexpected plugin path, no backslash found");
+
+ return std::wstring(path.begin(), it.base());
+ }
+ catch (const std::exception&)
+ {
+ return std::wstring();
+ }
+}
+
class DictionaryTest : public ::testing::Test
{
protected:
@@ -74,7 +109,7 @@
TEST_F(DictionaryTest, DefaultLocale)
{
- Dictionary::Create(L"en");
+ Dictionary::Create(L"en", basePath);
Dictionary* dict = Dictionary::GetInstance();
ASSERT_TRUE(dict);
@@ -88,7 +123,7 @@
TEST_F(DictionaryTest, LocaleFallback)
{
- Dictionary::Create(L"es-ES");
+ Dictionary::Create(L"es-ES", basePath);
Dictionary* dict = Dictionary::GetInstance();
ASSERT_TRUE(dict);
@@ -98,7 +133,7 @@
TEST_F(DictionaryTest, LocaleFallbackShort)
{
- Dictionary::Create(L"ru-RU");
+ Dictionary::Create(L"ru-RU", basePath);
Dictionary* dict = Dictionary::GetInstance();
ASSERT_TRUE(dict);
« no previous file with comments | « src/shared/Utils.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld