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

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

Issue 1886913002: Convert //chrome/browser/metrics from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 27 matching lines...) Expand all
38 38
39 } // namespace 39 } // namespace
40 40
41 TEST(ThreadWatcherAndroidTest, ApplicationStatusNotification) { 41 TEST(ThreadWatcherAndroidTest, ApplicationStatusNotification) {
42 // Do not delay the ThreadWatcherList initialization for this test. 42 // Do not delay the ThreadWatcherList initialization for this test.
43 ThreadWatcherList::g_initialize_delay_seconds = 0; 43 ThreadWatcherList::g_initialize_delay_seconds = 0;
44 44
45 base::MessageLoopForUI message_loop_for_ui; 45 base::MessageLoopForUI message_loop_for_ui;
46 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop_for_ui); 46 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop_for_ui);
47 47
48 48 std::unique_ptr<WatchDogThread> watchdog_thread_(new WatchDogThread());
49 scoped_ptr<WatchDogThread> watchdog_thread_(new WatchDogThread());
50 watchdog_thread_->StartAndWaitForTesting(); 49 watchdog_thread_->StartAndWaitForTesting();
51 50
52 EXPECT_FALSE(ThreadWatcherList::g_thread_watcher_list_); 51 EXPECT_FALSE(ThreadWatcherList::g_thread_watcher_list_);
53 52
54 53
55 // Register, and notify the application has just started, 54 // Register, and notify the application has just started,
56 // and ensure the thread watcher list is created. 55 // and ensure the thread watcher list is created.
57 ThreadWatcherAndroid::RegisterApplicationStatusListener(); 56 ThreadWatcherAndroid::RegisterApplicationStatusListener();
58 ThreadWatcherList::StartWatchingAll(*base::CommandLine::ForCurrentProcess()); 57 ThreadWatcherList::StartWatchingAll(*base::CommandLine::ForCurrentProcess());
59 NotifyApplicationStateChange( 58 NotifyApplicationStateChange(
60 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES); 59 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES);
61 EXPECT_TRUE(ThreadWatcherList::g_thread_watcher_list_); 60 EXPECT_TRUE(ThreadWatcherList::g_thread_watcher_list_);
62 61
63 // Notify the application has been stopped, and ensure the thread watcher list 62 // Notify the application has been stopped, and ensure the thread watcher list
64 // has been destroyed. 63 // has been destroyed.
65 NotifyApplicationStateChange( 64 NotifyApplicationStateChange(
66 base::android::APPLICATION_STATE_HAS_STOPPED_ACTIVITIES); 65 base::android::APPLICATION_STATE_HAS_STOPPED_ACTIVITIES);
67 EXPECT_FALSE(ThreadWatcherList::g_thread_watcher_list_); 66 EXPECT_FALSE(ThreadWatcherList::g_thread_watcher_list_);
68 67
69 // And again the last transition, STOPPED -> STARTED. 68 // And again the last transition, STOPPED -> STARTED.
70 NotifyApplicationStateChange( 69 NotifyApplicationStateChange(
71 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES); 70 base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES);
72 EXPECT_TRUE(ThreadWatcherList::g_thread_watcher_list_); 71 EXPECT_TRUE(ThreadWatcherList::g_thread_watcher_list_);
73 72
74 // ThreadWatcherList::StartWatchingAll() creates g_thread_watcher_observer_. 73 // ThreadWatcherList::StartWatchingAll() creates g_thread_watcher_observer_.
75 // This should be released by ThreadWatcherList::StopWatchingAll() in the end 74 // This should be released by ThreadWatcherList::StopWatchingAll() in the end
76 // of test to not affect other test cases. 75 // of test to not affect other test cases.
77 ThreadWatcherList::StopWatchingAll(); 76 ThreadWatcherList::StopWatchingAll();
78 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698