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

Side by Side Diff: chrome/browser/chromeos/arc/arc_session_manager_browsertest.cc

Issue 2561023002: arc: ARC loading progress should not be shown when started from OOBE. (Closed)
Patch Set: refactored 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chromeos/arc/arc_service_launcher.h" 16 #include "chrome/browser/chromeos/arc/arc_service_launcher.h"
17 #include "chrome/browser/chromeos/arc/arc_session_manager.h" 17 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
18 #include "chrome/browser/chromeos/arc/arc_session_manager_data_removed_waiter.h"
18 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 19 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
19 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 20 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
20 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 21 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
21 #include "chrome/browser/policy/cloud/test_request_interceptor.h" 22 #include "chrome/browser/policy/cloud/test_request_interceptor.h"
22 #include "chrome/browser/policy/profile_policy_connector.h" 23 #include "chrome/browser/policy/profile_policy_connector.h"
23 #include "chrome/browser/policy/profile_policy_connector_factory.h" 24 #include "chrome/browser/policy/profile_policy_connector_factory.h"
24 #include "chrome/browser/policy/test/local_policy_test_server.h" 25 #include "chrome/browser/policy/test/local_policy_test_server.h"
25 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" 27 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 28 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return; 91 return;
91 run_loop_->Quit(); 92 run_loop_->Quit();
92 } 93 }
93 94
94 private: 95 private:
95 std::unique_ptr<base::RunLoop> run_loop_; 96 std::unique_ptr<base::RunLoop> run_loop_;
96 97
97 DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerShutdownObserver); 98 DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerShutdownObserver);
98 }; 99 };
99 100
100 // Observer of ARC data has been removed.
101 class ArcSessionManagerDataRemovedObserver
102 : public ArcSessionManager::Observer {
103 public:
104 ArcSessionManagerDataRemovedObserver() {
105 ArcSessionManager::Get()->AddObserver(this);
106 }
107
108 ~ArcSessionManagerDataRemovedObserver() override {
109 ArcSessionManager::Get()->RemoveObserver(this);
110 }
111
112 void Wait() {
113 run_loop_.reset(new base::RunLoop);
114 run_loop_->Run();
115 run_loop_.reset();
116 }
117
118 // ArcSessionManager::Observer:
119 void OnArcDataRemoved() override {
120 if (!run_loop_)
121 return;
122 run_loop_->Quit();
123 }
124
125 private:
126 std::unique_ptr<base::RunLoop> run_loop_;
127
128 DISALLOW_COPY_AND_ASSIGN(ArcSessionManagerDataRemovedObserver);
129 };
130
131 class ArcSessionManagerTest : public InProcessBrowserTest { 101 class ArcSessionManagerTest : public InProcessBrowserTest {
132 protected: 102 protected:
133 ArcSessionManagerTest() {} 103 ArcSessionManagerTest() {}
134 104
135 // InProcessBrowserTest: 105 // InProcessBrowserTest:
136 ~ArcSessionManagerTest() override {} 106 ~ArcSessionManagerTest() override {}
137 107
138 void SetUpInProcessBrowserTestFixture() override { 108 void SetUpInProcessBrowserTestFixture() override {
139 // Start test device management server. 109 // Start test device management server.
140 test_server_.reset(new policy::LocalPolicyTestServer()); 110 test_server_.reset(new policy::LocalPolicyTestServer());
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 #else 237 #else
268 #define MAYBE_ManagedAndroidAccount ManagedAndroidAccount 238 #define MAYBE_ManagedAndroidAccount ManagedAndroidAccount
269 #endif 239 #endif
270 IN_PROC_BROWSER_TEST_F(ArcSessionManagerTest, MAYBE_ManagedAndroidAccount) { 240 IN_PROC_BROWSER_TEST_F(ArcSessionManagerTest, MAYBE_ManagedAndroidAccount) {
271 EnableArc(); 241 EnableArc();
272 token_service()->IssueTokenForAllPendingRequests(kManagedAuthToken, 242 token_service()->IssueTokenForAllPendingRequests(kManagedAuthToken,
273 base::Time::Max()); 243 base::Time::Max());
274 ArcSessionManagerShutdownObserver().Wait(); 244 ArcSessionManagerShutdownObserver().Wait();
275 ASSERT_EQ(ArcSessionManager::State::REMOVING_DATA_DIR, 245 ASSERT_EQ(ArcSessionManager::State::REMOVING_DATA_DIR,
276 ArcSessionManager::Get()->state()); 246 ArcSessionManager::Get()->state());
277 ArcSessionManagerDataRemovedObserver().Wait(); 247 ArcSessionManagerDataRemovedWaiter().Wait();
278 ASSERT_EQ(ArcSessionManager::State::STOPPED, 248 ASSERT_EQ(ArcSessionManager::State::STOPPED,
279 ArcSessionManager::Get()->state()); 249 ArcSessionManager::Get()->state());
280 } 250 }
281 251
282 } // namespace arc 252 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698