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

Unified Diff: chrome/browser/lifetime/keep_alive_registry_unittest.cc

Issue 1778873002: Replace Increment/DecrementKeepAliveCount by ScopedKeepAlives (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@KAObserver
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/lifetime/keep_alive_registry_unittest.cc
diff --git a/chrome/browser/lifetime/keep_alive_registry_unittest.cc b/chrome/browser/lifetime/keep_alive_registry_unittest.cc
index b2916ec0e9ad164437d32feb7ee304e5f39c6efa..759309d5c43d6646bcc38b872cc1fb56b3bd4705 100644
--- a/chrome/browser/lifetime/keep_alive_registry_unittest.cc
+++ b/chrome/browser/lifetime/keep_alive_registry_unittest.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/lifetime/keep_alive_state_observer.h"
#include "chrome/browser/lifetime/keep_alive_types.h"
#include "chrome/browser/lifetime/scoped_keep_alive.h"
+#include "chrome/test/base/testing_browser_process.h"
#include "testing/gtest/include/gtest/gtest.h"
class KeepAliveRegistryTest : public testing::Test,
@@ -45,7 +46,8 @@ class KeepAliveRegistryTest : public testing::Test,
// Test the IsKeepingAlive state and when we interact with the browser with
// a KeepAlive registered.
TEST_F(KeepAliveRegistryTest, BasicKeepAliveTest) {
- const int base_keep_alive_count = chrome::GetKeepAliveCountForTesting();
+ TestingBrowserProcess* browser_process = TestingBrowserProcess::GetGlobal();
+ const int base_module_ref_count = browser_process->GetModuleRefCount();
KeepAliveRegistry* registry = KeepAliveRegistry::GetInstance();
EXPECT_FALSE(registry->IsKeepingAlive());
@@ -56,39 +58,40 @@ TEST_F(KeepAliveRegistryTest, BasicKeepAliveTest) {
KeepAliveRestartOption::DISABLED);
// We should require the browser to stay alive
- EXPECT_EQ(base_keep_alive_count + 1, chrome::GetKeepAliveCountForTesting());
+ EXPECT_EQ(base_module_ref_count + 1, browser_process->GetModuleRefCount());
EXPECT_TRUE(registry_->IsKeepingAlive());
}
// We should be back to normal now.
- EXPECT_EQ(base_keep_alive_count, chrome::GetKeepAliveCountForTesting());
+ EXPECT_EQ(base_module_ref_count, browser_process->GetModuleRefCount());
EXPECT_FALSE(registry_->IsKeepingAlive());
}
// Test the IsKeepingAlive state and when we interact with the browser with
// more than one KeepAlive registered.
TEST_F(KeepAliveRegistryTest, DoubleKeepAliveTest) {
- const int base_keep_alive_count = chrome::GetKeepAliveCountForTesting();
+ TestingBrowserProcess* browser_process = TestingBrowserProcess::GetGlobal();
+ const int base_module_ref_count = browser_process->GetModuleRefCount();
scoped_ptr<ScopedKeepAlive> keep_alive_1, keep_alive_2;
keep_alive_1.reset(new ScopedKeepAlive(KeepAliveOrigin::CHROME_APP_DELEGATE,
KeepAliveRestartOption::DISABLED));
- EXPECT_EQ(base_keep_alive_count + 1, chrome::GetKeepAliveCountForTesting());
+ EXPECT_EQ(base_module_ref_count + 1, browser_process->GetModuleRefCount());
EXPECT_TRUE(registry_->IsKeepingAlive());
keep_alive_2.reset(new ScopedKeepAlive(KeepAliveOrigin::CHROME_APP_DELEGATE,
KeepAliveRestartOption::DISABLED));
// We should not increment the count twice
- EXPECT_EQ(base_keep_alive_count + 1, chrome::GetKeepAliveCountForTesting());
+ EXPECT_EQ(base_module_ref_count + 1, browser_process->GetModuleRefCount());
EXPECT_TRUE(registry_->IsKeepingAlive());
keep_alive_1.reset();
// We should not decrement the count before the last keep alive is released.
- EXPECT_EQ(base_keep_alive_count + 1, chrome::GetKeepAliveCountForTesting());
+ EXPECT_EQ(base_module_ref_count + 1, browser_process->GetModuleRefCount());
EXPECT_TRUE(registry_->IsKeepingAlive());
keep_alive_2.reset();
- EXPECT_EQ(base_keep_alive_count, chrome::GetKeepAliveCountForTesting());
+ EXPECT_EQ(base_module_ref_count, browser_process->GetModuleRefCount());
EXPECT_FALSE(registry_->IsKeepingAlive());
}

Powered by Google App Engine
This is Rietveld 408576698