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

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

Issue 2711033002: Fix Arc integration test. (Closed)
Patch Set: 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 "chrome/browser/chromeos/arc/arc_session_manager.h" 5 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/shelf/shelf_delegate.h" 9 #include "ash/common/shelf/shelf_delegate.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 namespace arc { 53 namespace arc {
54 54
55 namespace { 55 namespace {
56 56
57 // Weak pointer. This class is owned by ArcServiceManager. 57 // Weak pointer. This class is owned by ArcServiceManager.
58 ArcSessionManager* g_arc_session_manager = nullptr; 58 ArcSessionManager* g_arc_session_manager = nullptr;
59 59
60 // Skip creating UI in unit tests 60 // Skip creating UI in unit tests
61 bool g_disable_ui_for_testing = false; 61 bool g_disable_ui_for_testing = false;
62 62
63 // Skip DCHECK(state() == State::REMOVING_DATA_DIR) in OnArcDataRemoved.
64 bool g_is_session_manager_for_sync_test = false;
65
63 // Use specified ash::ShelfDelegate for unit tests. 66 // Use specified ash::ShelfDelegate for unit tests.
64 ash::ShelfDelegate* g_shelf_delegate_for_testing = nullptr; 67 ash::ShelfDelegate* g_shelf_delegate_for_testing = nullptr;
65 68
66 // The Android management check is disabled by default, it's used only for 69 // The Android management check is disabled by default, it's used only for
67 // testing. 70 // testing.
68 bool g_enable_check_android_management_for_testing = false; 71 bool g_enable_check_android_management_for_testing = false;
69 72
70 // Maximum amount of time we'll wait for ARC to finish booting up. Once this 73 // Maximum amount of time we'll wait for ARC to finish booting up. Once this
71 // timeout expires, keep ARC running in case the user wants to file feedback, 74 // timeout expires, keep ARC running in case the user wants to file feedback,
72 // but present the UI to try again. 75 // but present the UI to try again.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 void ArcSessionManager::SetShelfDelegateForTesting( 152 void ArcSessionManager::SetShelfDelegateForTesting(
150 ash::ShelfDelegate* shelf_delegate) { 153 ash::ShelfDelegate* shelf_delegate) {
151 g_shelf_delegate_for_testing = shelf_delegate; 154 g_shelf_delegate_for_testing = shelf_delegate;
152 } 155 }
153 156
154 // static 157 // static
155 void ArcSessionManager::EnableCheckAndroidManagementForTesting() { 158 void ArcSessionManager::EnableCheckAndroidManagementForTesting() {
156 g_enable_check_android_management_for_testing = true; 159 g_enable_check_android_management_for_testing = true;
157 } 160 }
158 161
162 // static
163 void ArcSessionManager::SetSessionManagerForSyncTest() {
164 g_is_session_manager_for_sync_test = true;
165 }
166
159 void ArcSessionManager::OnSessionReady() { 167 void ArcSessionManager::OnSessionReady() {
160 for (auto& observer : arc_session_observer_list_) 168 for (auto& observer : arc_session_observer_list_)
161 observer.OnSessionReady(); 169 observer.OnSessionReady();
162 } 170 }
163 171
164 void ArcSessionManager::OnSessionStopped(StopReason reason) { 172 void ArcSessionManager::OnSessionStopped(StopReason reason) {
165 // TODO(crbug.com/625923): Use |reason| to report more detailed errors. 173 // TODO(crbug.com/625923): Use |reason| to report more detailed errors.
166 if (arc_sign_in_timer_.IsRunning()) 174 if (arc_sign_in_timer_.IsRunning())
167 OnProvisioningFinished(ProvisioningResult::ARC_STOPPED); 175 OnProvisioningFinished(ProvisioningResult::ARC_STOPPED);
168 176
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 LOG(ERROR) << "Request for ARC user data removal failed."; 223 LOG(ERROR) << "Request for ARC user data removal failed.";
216 224
217 // TODO(khmel): Browser tests may shutdown profile by itself. Update browser 225 // TODO(khmel): Browser tests may shutdown profile by itself. Update browser
218 // tests and remove this check. 226 // tests and remove this check.
219 if (state() == State::NOT_INITIALIZED) 227 if (state() == State::NOT_INITIALIZED)
220 return; 228 return;
221 229
222 for (auto& observer : observer_list_) 230 for (auto& observer : observer_list_)
223 observer.OnArcDataRemoved(); 231 observer.OnArcDataRemoved();
224 232
225 profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, false); 233 profile_->GetPrefs()->SetBoolean(prefs::kArcDataRemoveRequested, false);
lgcheng 2017/02/22 23:36:44 state() is confused when multiple profiles are cre
hidehiko 2017/02/23 06:31:45 Instead, could you avoid confusing the state machi
226 DCHECK_EQ(state(), State::REMOVING_DATA_DIR); 234 DCHECK(state() == State::REMOVING_DATA_DIR ||
235 g_is_session_manager_for_sync_test);
227 SetState(State::STOPPED); 236 SetState(State::STOPPED);
228 237
229 MaybeReenableArc(); 238 MaybeReenableArc();
230 } 239 }
231 240
232 void ArcSessionManager::MaybeReenableArc() { 241 void ArcSessionManager::MaybeReenableArc() {
233 // Here check if |reenable_arc_| is marked or not. 242 // Here check if |reenable_arc_| is marked or not.
234 // The only case this happens should be in the special case for enterprise 243 // The only case this happens should be in the special case for enterprise
235 // "on managed lost" case. In that case, OnSessionStopped() should trigger 244 // "on managed lost" case. In that case, OnSessionStopped() should trigger
236 // the RemoveArcData(), then this. 245 // the RemoveArcData(), then this.
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 1017
1009 #undef MAP_STATE 1018 #undef MAP_STATE
1010 1019
1011 // Some compilers report an error even if all values of an enum-class are 1020 // Some compilers report an error even if all values of an enum-class are
1012 // covered exhaustively in a switch statement. 1021 // covered exhaustively in a switch statement.
1013 NOTREACHED() << "Invalid value " << static_cast<int>(state); 1022 NOTREACHED() << "Invalid value " << static_cast<int>(state);
1014 return os; 1023 return os;
1015 } 1024 }
1016 1025
1017 } // namespace arc 1026 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698