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

Side by Side Diff: chrome/browser/metrics/thread_watcher_android_unittest.cc

Issue 2041033003: clang-tidy WaitableEvent refactor (Android side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0_windows
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 5
6 #include "base/android/application_status_listener.h" 6 #include "base/android/application_status_listener.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 #include "chrome/browser/metrics/thread_watcher.h" 9 #include "chrome/browser/metrics/thread_watcher.h"
10 #include "chrome/browser/metrics/thread_watcher_android.h" 10 #include "chrome/browser/metrics/thread_watcher_android.h"
(...skipping 10 matching lines...) Expand all
21 void PostAndWaitForWatchdogThread(base::WaitableEvent* event) { 21 void PostAndWaitForWatchdogThread(base::WaitableEvent* event) {
22 WatchDogThread::PostDelayedTask( 22 WatchDogThread::PostDelayedTask(
23 FROM_HERE, 23 FROM_HERE,
24 base::Bind(&OnThreadWatcherTask, event), 24 base::Bind(&OnThreadWatcherTask, event),
25 base::TimeDelta::FromSeconds(0)); 25 base::TimeDelta::FromSeconds(0));
26 26
27 EXPECT_TRUE(event->TimedWait(base::TimeDelta::FromSeconds(1))); 27 EXPECT_TRUE(event->TimedWait(base::TimeDelta::FromSeconds(1)));
28 } 28 }
29 29
30 void NotifyApplicationStateChange(base::android::ApplicationState state) { 30 void NotifyApplicationStateChange(base::android::ApplicationState state) {
31 base::WaitableEvent watchdog_thread_event(false, false); 31 base::WaitableEvent watchdog_thread_event(
32 base::WaitableEvent::ResetPolicy::AUTOMATIC,
33 base::WaitableEvent::InitialState::NOT_SIGNALED);
32 34
33 base::android::ApplicationStatusListener::NotifyApplicationStateChange(state); 35 base::android::ApplicationStatusListener::NotifyApplicationStateChange(state);
34 base::RunLoop().RunUntilIdle(); 36 base::RunLoop().RunUntilIdle();
35 37
36 PostAndWaitForWatchdogThread(&watchdog_thread_event); 38 PostAndWaitForWatchdogThread(&watchdog_thread_event);
37 } 39 }
38 40
39 } // namespace 41 } // namespace
40 42
41 TEST(ThreadWatcherAndroidTest, ApplicationStatusNotification) { 43 TEST(ThreadWatcherAndroidTest, ApplicationStatusNotification) {
(...skipping 26 matching lines...) Expand all
68 // And again the last transition, STOPPED -> STARTED. 70 // And again the last transition, STOPPED -> STARTED.
69 NotifyApplicationStateChange( 71 NotifyApplicationStateChange(
70 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES); 72 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES);
71 EXPECT_TRUE(ThreadWatcherList::g_thread_watcher_list_); 73 EXPECT_TRUE(ThreadWatcherList::g_thread_watcher_list_);
72 74
73 // ThreadWatcherList::StartWatchingAll() creates g_thread_watcher_observer_. 75 // ThreadWatcherList::StartWatchingAll() creates g_thread_watcher_observer_.
74 // This should be released by ThreadWatcherList::StopWatchingAll() in the end 76 // This should be released by ThreadWatcherList::StopWatchingAll() in the end
75 // of test to not affect other test cases. 77 // of test to not affect other test cases.
76 ThreadWatcherList::StopWatchingAll(); 78 ThreadWatcherList::StopWatchingAll();
77 } 79 }
OLDNEW
« no previous file with comments | « chrome/browser/history/android/sqlite_cursor.cc ('k') | chrome/chrome_watcher/chrome_watcher_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698