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

Side by Side Diff: rlz/test/rlz_test_helpers.cc

Issue 11365107: [cros] RlzValueStore implementation for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert to Chrome-only Created 8 years, 1 month 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 | « rlz/test/rlz_test_helpers.h ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Main entry point for all unit tests. 5 // Main entry point for all unit tests.
6 6
7 #include "rlz_test_helpers.h" 7 #include "rlz_test_helpers.h"
8 8
9 #include "rlz/lib/rlz_lib.h" 9 #include "rlz/lib/rlz_lib.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 #if defined(OS_WIN) 12 #if defined(OS_WIN)
13 #include <shlwapi.h> 13 #include <shlwapi.h>
14 #include "base/win/registry.h" 14 #include "base/win/registry.h"
15 #include "rlz/win/lib/rlz_lib.h" 15 #include "rlz/win/lib/rlz_lib.h"
16 #elif defined(OS_MACOSX) 16 #elif defined(OS_MACOSX) || defined(OS_CHROMEOS)
17 #include "base/file_path.h" 17 #include "base/file_path.h"
18 #include "rlz/lib/rlz_value_store.h" 18 #include "rlz/lib/rlz_value_store.h"
19 #endif 19 #endif
20 #if defined(OS_CHROMEOS)
21 #include "rlz/chromeos/lib/rlz_value_store_chromeos.h"
22 #endif
20 23
21 #if defined(OS_WIN) 24 #if defined(OS_WIN)
22 namespace { 25 namespace {
23 26
24 const wchar_t* kHKCUReplacement = L"Software\\Google\\RlzUtilUnittest\\HKCU"; 27 const wchar_t* kHKCUReplacement = L"Software\\Google\\RlzUtilUnittest\\HKCU";
25 const wchar_t* kHKLMReplacement = L"Software\\Google\\RlzUtilUnittest\\HKLM"; 28 const wchar_t* kHKLMReplacement = L"Software\\Google\\RlzUtilUnittest\\HKLM";
26 29
27 void OverrideRegistryHives() { 30 void OverrideRegistryHives() {
28 // Wipe the keys we redirect to. 31 // Wipe the keys we redirect to.
29 // This gives us a stable run, even in the presence of previous 32 // This gives us a stable run, even in the presence of previous
(...skipping 23 matching lines...) Expand all
53 void UndoOverrideRegistryHives() { 56 void UndoOverrideRegistryHives() {
54 // Undo the redirection. 57 // Undo the redirection.
55 EXPECT_EQ(ERROR_SUCCESS, ::RegOverridePredefKey(HKEY_CURRENT_USER, NULL)); 58 EXPECT_EQ(ERROR_SUCCESS, ::RegOverridePredefKey(HKEY_CURRENT_USER, NULL));
56 EXPECT_EQ(ERROR_SUCCESS, ::RegOverridePredefKey(HKEY_LOCAL_MACHINE, NULL)); 59 EXPECT_EQ(ERROR_SUCCESS, ::RegOverridePredefKey(HKEY_LOCAL_MACHINE, NULL));
57 } 60 }
58 61
59 } // namespace 62 } // namespace
60 #endif // defined(OS_WIN) 63 #endif // defined(OS_WIN)
61 64
62 65
66 #if defined(OS_CHROMEOS)
67 RlzLibTestNoMachineState::RlzLibTestNoMachineState()
68 : pref_store_io_thread_("test_rlz_pref_store_io_thread") {
69 }
70 #endif // defined(OS_CHROMEOS)
71
63 void RlzLibTestNoMachineState::SetUp() { 72 void RlzLibTestNoMachineState::SetUp() {
64 #if defined(OS_WIN) 73 #if defined(OS_WIN)
65 OverrideRegistryHives(); 74 OverrideRegistryHives();
66 #elif defined(OS_MACOSX) 75 #elif defined(OS_MACOSX)
67 base::mac::ScopedNSAutoreleasePool pool; 76 base::mac::ScopedNSAutoreleasePool pool;
77 #endif // defined(OS_WIN)
78 #if defined(OS_MACOSX) || defined(OS_CHROMEOS)
68 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 79 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
69 rlz_lib::testing::SetRlzStoreDirectory(temp_dir_.path()); 80 rlz_lib::testing::SetRlzStoreDirectory(temp_dir_.path());
70 #endif // defined(OS_WIN) 81 #endif // defined(OS_MACOSX) || defined(OS_CHROMEOS)
82 #if defined(OS_CHROMEOS)
83 base::Thread::Options options;
84 options.message_loop_type = MessageLoop::TYPE_IO;
85 ASSERT_TRUE(pref_store_io_thread_.StartWithOptions(options));
86 rlz_lib::SetIOTaskRunner(pref_store_io_thread_.message_loop_proxy());
87 rlz_lib::RlzValueStoreChromeOS::ResetForTesting();
88 #endif // defined(OS_CHROMEOS)
71 } 89 }
72 90
73 void RlzLibTestNoMachineState::TearDown() { 91 void RlzLibTestNoMachineState::TearDown() {
74 #if defined(OS_WIN) 92 #if defined(OS_WIN)
75 UndoOverrideRegistryHives(); 93 UndoOverrideRegistryHives();
76 #elif defined(OS_MACOSX) 94 #elif defined(OS_MACOSX) || defined(OS_CHROMEOS)
77 rlz_lib::testing::SetRlzStoreDirectory(FilePath()); 95 rlz_lib::testing::SetRlzStoreDirectory(FilePath());
78 #endif // defined(OS_WIN) 96 #endif // defined(OS_WIN)
97 #if defined(OS_CHROMEOS)
98 pref_store_io_thread_.Stop();
99 #endif // defined(OS_CHROMEOS)
79 } 100 }
80 101
81 void RlzLibTestBase::SetUp() { 102 void RlzLibTestBase::SetUp() {
82 RlzLibTestNoMachineState::SetUp(); 103 RlzLibTestNoMachineState::SetUp();
83 #if defined(OS_WIN) 104 #if defined(OS_WIN)
84 rlz_lib::CreateMachineState(); 105 rlz_lib::CreateMachineState();
85 #endif // defined(OS_WIN) 106 #endif // defined(OS_WIN)
86 } 107 }
OLDNEW
« no previous file with comments | « rlz/test/rlz_test_helpers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698