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

Unified Diff: mandoline/ui/browser/browser_apptest.cc

Issue 1254383016: ApplicationConnection lifetime management changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 4 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: mandoline/ui/browser/browser_apptest.cc
diff --git a/mandoline/ui/browser/browser_apptest.cc b/mandoline/ui/browser/browser_apptest.cc
index f99a842ceb0cd68ee0bbe14a5ef196fe4f6fdb8d..ea682b85268fa6669fa77b150e775d9b127383f3 100644
--- a/mandoline/ui/browser/browser_apptest.cc
+++ b/mandoline/ui/browser/browser_apptest.cc
@@ -52,7 +52,6 @@ class BrowserTest : public mojo::test::ApplicationTestBase,
public:
BrowserTest()
: app_(nullptr),
- last_closed_connection_(nullptr),
last_browser_closed_(nullptr) {}
// Creates a new Browser object.
@@ -75,21 +74,11 @@ class BrowserTest : public mojo::test::ApplicationTestBase,
return last_browser;
}
- // Returns the last ApplicationConnection closed.
- void* last_closed_connection() {
- return last_closed_connection_;
- }
-
// Overridden from ApplicationDelegate:
void Initialize(mojo::ApplicationImpl* app) override {
app_ = app;
}
- void OnWillCloseConnection(mojo::ApplicationConnection* connection) override {
- // WARNING: DO NOT FOLLOW THIS POINTER. IT WILL BE DESTROYED.
- last_closed_connection_ = connection;
- }
-
// ApplicationTestBase:
ApplicationDelegate* GetApplicationDelegate() override { return this; }
@@ -110,7 +99,6 @@ class BrowserTest : public mojo::test::ApplicationTestBase,
private:
mojo::ApplicationImpl* app_;
- void* last_closed_connection_;
std::set<TestBrowser*> browsers_;
TestBrowser* last_browser_closed_;
scoped_ptr<base::RunLoop> browser_closed_run_loop_;
@@ -125,9 +113,12 @@ TEST_F(BrowserTest, ClosingBrowserClosesAppConnection) {
ASSERT_NE(nullptr, browser);
mojo::ApplicationConnection* view_manager_connection =
browser->view_manager_init_.connection();
+ base::WeakPtrFactory<mojo::ApplicationConnection> weak_factory(
+ view_manager_connection);
ASSERT_NE(nullptr, view_manager_connection);
+ base::WeakPtr<mojo::ApplicationConnection> ptr(weak_factory.GetWeakPtr());
BrowserClosed(browser);
- EXPECT_EQ(last_closed_connection(), view_manager_connection);
+ EXPECT_TRUE(ptr);
sky 2015/08/11 18:28:04 Won't this always be true? Also, this test is mean
}
// This test verifies that we can create two Browsers and each Browser has a

Powered by Google App Engine
This is Rietveld 408576698