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

Unified Diff: chrome/browser/chromeos/arc/arc_session_manager_browsertest.cc

Issue 2692993007: Remove ArcSessionManager::Observer::OnArcBridgeShutdown. (Closed)
Patch Set: Address comments Created 3 years, 10 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
« no previous file with comments | « chrome/browser/chromeos/arc/arc_session_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/arc/arc_session_manager_browsertest.cc
diff --git a/chrome/browser/chromeos/arc/arc_session_manager_browsertest.cc b/chrome/browser/chromeos/arc/arc_session_manager_browsertest.cc
index 7d7c96d5a844267e6c0416a4d264fa68527ee844..29dbb859781d039d3837c43042188f2f634b6f6c 100644
--- a/chrome/browser/chromeos/arc/arc_session_manager_browsertest.cc
+++ b/chrome/browser/chromeos/arc/arc_session_manager_browsertest.cc
@@ -5,6 +5,7 @@
#include <memory>
#include <string>
+#include "base/auto_reset.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
@@ -64,34 +65,33 @@ constexpr char kFakeGaiaId[] = "1234567890";
namespace arc {
-// Observer of ARC bridge shutdown.
-class ArcSessionManagerShutdownObserver : public ArcSessionManager::Observer {
+// Waits for the "arc.enabled" preference value from true to false.
+class ArcPlayStoreDisabledWaiter : public ArcSessionManager::Observer {
public:
- ArcSessionManagerShutdownObserver() {
- ArcSessionManager::Get()->AddObserver(this);
- }
+ ArcPlayStoreDisabledWaiter() { ArcSessionManager::Get()->AddObserver(this); }
- ~ArcSessionManagerShutdownObserver() override {
+ ~ArcPlayStoreDisabledWaiter() override {
ArcSessionManager::Get()->RemoveObserver(this);
}
void Wait() {
- run_loop_.reset(new base::RunLoop);
- run_loop_->Run();
- run_loop_.reset();
+ base::RunLoop run_loop;
+ base::AutoReset<base::RunLoop*> reset(&run_loop_, &run_loop);
+ run_loop.Run();
}
- // ArcSessionManager::Observer:
- void OnArcBridgeShutdown() override {
- if (!run_loop_)
- return;
- run_loop_->Quit();
+ private:
+ // ArcSessionManager::Observer override:
+ void OnArcPlayStoreEnabledChanged(bool enabled) override {
+ if (!enabled) {
+ DCHECK(run_loop_);
+ run_loop_->Quit();
+ }
}
- private:
- std::unique_ptr<base::RunLoop> run_loop_;
+ base::RunLoop* run_loop_ = nullptr;
- DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerShutdownObserver);
+ DISALLOW_COPY_AND_ASSIGN(ArcPlayStoreDisabledWaiter);
};
class ArcSessionManagerTest : public InProcessBrowserTest {
@@ -227,7 +227,7 @@ IN_PROC_BROWSER_TEST_F(ArcSessionManagerTest, ManagedAndroidAccount) {
EnableArc();
token_service()->IssueTokenForAllPendingRequests(kManagedAuthToken,
base::Time::Max());
- ArcSessionManagerShutdownObserver().Wait();
+ ArcPlayStoreDisabledWaiter().Wait();
ASSERT_EQ(ArcSessionManager::State::REMOVING_DATA_DIR,
ArcSessionManager::Get()->state());
ArcDataRemovedWaiter().Wait();
« no previous file with comments | « chrome/browser/chromeos/arc/arc_session_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698