gpu: Tweak Android WebGL test expectations
[chromium-blink-merge.git] / chrome_frame / test / registry_watcher_unittest.cc
blobc02c74920501dc47094bf82f78b2a54effc241c3
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/registry_watcher.h"
7 #include "base/synchronization/waitable_event.h"
8 #include "base/time/time.h"
9 #include "base/win/registry.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 using base::win::RegKey;
14 const wchar_t kTestRoot[] = L"CFRegistryWatcherTest";
15 const wchar_t kTestWindowClass[] = L"TestWndClass";
16 const wchar_t kTestWindowName[] = L"TestWndName";
18 // Give notifications 30 seconds to stick. Hopefully long enough to avoid
19 // flakiness.
20 const int64 kWaitSeconds = 30;
22 class RegistryWatcherUnittest : public testing::Test {
23 public:
24 void SetUp() {
25 // Create a temporary key for testing
26 temp_key_.Open(HKEY_CURRENT_USER, L"", KEY_QUERY_VALUE);
27 temp_key_.DeleteKey(kTestRoot);
28 ASSERT_NE(ERROR_SUCCESS, temp_key_.Open(HKEY_CURRENT_USER,
29 kTestRoot,
30 KEY_READ));
31 ASSERT_EQ(ERROR_SUCCESS,
32 temp_key_.Create(HKEY_CURRENT_USER, kTestRoot, KEY_READ));
34 reg_change_count_ = 0;
37 void TearDown() {
38 // Clean up the temporary key
39 temp_key_.Open(HKEY_CURRENT_USER, L"", KEY_QUERY_VALUE);
40 ASSERT_EQ(ERROR_SUCCESS, temp_key_.DeleteKey(kTestRoot));
41 temp_key_.Close();
43 reg_change_count_ = 0;
46 static void WaitCallback() {
47 reg_change_count_++;
48 event_.Signal();
51 protected:
52 RegKey temp_key_;
53 static unsigned int reg_change_count_;
54 static base::WaitableEvent event_;
57 unsigned int RegistryWatcherUnittest::reg_change_count_ = 0;
58 base::WaitableEvent RegistryWatcherUnittest::event_(
59 false, // auto reset
60 false); // initially unsignalled
62 TEST_F(RegistryWatcherUnittest, Basic) {
63 RegistryWatcher watcher(HKEY_CURRENT_USER,
64 kTestRoot,
65 &RegistryWatcherUnittest::WaitCallback);
66 ASSERT_TRUE(watcher.StartWatching());
67 EXPECT_EQ(0, reg_change_count_);
69 EXPECT_EQ(ERROR_SUCCESS, temp_key_.CreateKey(L"foo", KEY_ALL_ACCESS));
70 EXPECT_TRUE(event_.TimedWait(base::TimeDelta::FromSeconds(kWaitSeconds)));
71 EXPECT_EQ(1, reg_change_count_);