Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/sync/test/integration/apps_helper.h" | 5 #include "chrome/browser/sync/test/integration/apps_helper.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 std::string CreateFakeAppName(int index) { | 30 std::string CreateFakeAppName(int index) { |
| 31 return "fakeapp" + base::IntToString(index); | 31 return "fakeapp" + base::IntToString(index); |
| 32 } | 32 } |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 namespace apps_helper { | 36 namespace apps_helper { |
| 37 | 37 |
| 38 bool HasSameAppsAsVerifier(int index) { | 38 bool HasSameApps(Profile* profile1, Profile* profile2) { |
| 39 return SyncAppHelper::GetInstance()->AppStatesMatch( | 39 return SyncAppHelper::GetInstance()->AppStatesMatch(profile1, profile2); |
| 40 test()->GetProfile(index), test()->verifier()); | |
| 41 } | 40 } |
| 42 | 41 |
| 43 bool AllProfilesHaveSameAppsAsVerifier() { | 42 bool HasSameAppsAsVerifier(int index) { |
|
Nicolas Zea
2016/03/31 19:01:21
can this be deleted?
shadi
2016/03/31 22:46:47
Done.
| |
| 44 for (int i = 0; i < test()->num_clients(); ++i) { | 43 return HasSameApps(test()->GetProfile(index), test()->verifier()); |
| 45 if (!HasSameAppsAsVerifier(i)) { | 44 } |
| 46 DVLOG(1) << "Profile " << i << " doesn't have the same apps as the" | 45 |
| 47 " verifier profile."; | 46 bool AllProfilesHaveSameApps() { |
| 47 std::vector<Profile*> profiles = test()->GetAllProfiles(); | |
| 48 std::vector<Profile*>::iterator it = profiles.begin(); | |
| 49 Profile* profile0 = *it; | |
|
Nicolas Zea
2016/03/31 19:01:21
nit: have this be part of for loop? I think you ca
shadi
2016/03/31 22:46:47
Done.
| |
| 50 ++it; | |
| 51 for (; it != profiles.end(); ++it) { | |
| 52 if (!HasSameApps(profile0, *it)) { | |
| 53 DVLOG(1) << "Profiles apps do not match."; | |
| 48 return false; | 54 return false; |
| 49 } | 55 } |
| 50 } | 56 } |
| 51 return true; | 57 return true; |
| 52 } | 58 } |
| 53 | 59 |
| 54 std::string InstallApp(Profile* profile, int index) { | 60 std::string InstallApp(Profile* profile, int index) { |
| 55 return SyncExtensionHelper::GetInstance()->InstallExtension( | 61 return SyncExtensionHelper::GetInstance()->InstallExtension( |
| 56 profile, | 62 profile, |
| 57 CreateFakeAppName(index), | 63 CreateFakeAppName(index), |
| 58 extensions::Manifest::TYPE_HOSTED_APP); | 64 extensions::Manifest::TYPE_HOSTED_APP); |
| 59 } | 65 } |
| 60 | 66 |
| 61 std::string InstallPlatformApp(Profile* profile, int index) { | 67 std::string InstallPlatformApp(Profile* profile, int index) { |
| 62 return SyncExtensionHelper::GetInstance()->InstallExtension( | 68 return SyncExtensionHelper::GetInstance()->InstallExtension( |
| 63 profile, | 69 profile, |
| 64 CreateFakeAppName(index), | 70 CreateFakeAppName(index), |
| 65 extensions::Manifest::TYPE_PLATFORM_APP); | 71 extensions::Manifest::TYPE_PLATFORM_APP); |
| 66 } | 72 } |
| 67 | 73 |
| 68 std::string InstallAppForAllProfiles(int index) { | 74 std::string InstallAppForAllProfiles(int index) { |
| 69 for (int i = 0; i < test()->num_clients(); ++i) | 75 std::string extension_id; |
| 70 InstallApp(test()->GetProfile(i), index); | 76 std::vector<Profile*> profiles = test()->GetAllProfiles(); |
| 71 return InstallApp(test()->verifier(), index); | 77 for (std::vector<Profile*>::iterator it = profiles.begin(); |
| 78 it != profiles.end(); | |
| 79 ++it) { | |
| 80 extension_id = InstallApp(*it, index); | |
| 81 } | |
| 82 return extension_id; | |
| 72 } | 83 } |
| 73 | 84 |
| 74 void UninstallApp(Profile* profile, int index) { | 85 void UninstallApp(Profile* profile, int index) { |
| 75 return SyncExtensionHelper::GetInstance()->UninstallExtension( | 86 return SyncExtensionHelper::GetInstance()->UninstallExtension( |
| 76 profile, CreateFakeAppName(index)); | 87 profile, CreateFakeAppName(index)); |
| 77 } | 88 } |
| 78 | 89 |
| 79 void EnableApp(Profile* profile, int index) { | 90 void EnableApp(Profile* profile, int index) { |
| 80 return SyncExtensionHelper::GetInstance()->EnableExtension( | 91 return SyncExtensionHelper::GetInstance()->EnableExtension( |
| 81 profile, CreateFakeAppName(index)); | 92 profile, CreateFakeAppName(index)); |
| 82 } | 93 } |
| 83 | 94 |
| 84 void DisableApp(Profile* profile, int index) { | 95 void DisableApp(Profile* profile, int index) { |
| 85 return SyncExtensionHelper::GetInstance()->DisableExtension( | 96 return SyncExtensionHelper::GetInstance()->DisableExtension( |
| 86 profile, CreateFakeAppName(index)); | 97 profile, CreateFakeAppName(index)); |
| 87 } | 98 } |
| 88 | 99 |
| 100 bool IsAppEnabled(Profile* profile, int index) { | |
| 101 return SyncExtensionHelper::GetInstance()->IsExtensionEnabled( | |
| 102 profile, CreateFakeAppName(index)); | |
| 103 } | |
| 104 | |
| 89 void IncognitoEnableApp(Profile* profile, int index) { | 105 void IncognitoEnableApp(Profile* profile, int index) { |
| 90 return SyncExtensionHelper::GetInstance()->IncognitoEnableExtension( | 106 return SyncExtensionHelper::GetInstance()->IncognitoEnableExtension( |
| 91 profile, CreateFakeAppName(index)); | 107 profile, CreateFakeAppName(index)); |
| 92 } | 108 } |
| 93 | 109 |
| 94 void IncognitoDisableApp(Profile* profile, int index) { | 110 void IncognitoDisableApp(Profile* profile, int index) { |
| 95 return SyncExtensionHelper::GetInstance()->IncognitoDisableExtension( | 111 return SyncExtensionHelper::GetInstance()->IncognitoDisableExtension( |
| 96 profile, CreateFakeAppName(index)); | 112 profile, CreateFakeAppName(index)); |
| 97 } | 113 } |
| 98 | 114 |
| 115 bool IsIncognitoEnabled(Profile* profile, int index) { | |
| 116 return SyncExtensionHelper::GetInstance()->IsIncognitoEnabled( | |
| 117 profile, CreateFakeAppName(index)); | |
| 118 } | |
| 119 | |
| 99 void InstallAppsPendingForSync(Profile* profile) { | 120 void InstallAppsPendingForSync(Profile* profile) { |
| 100 SyncExtensionHelper::GetInstance()->InstallExtensionsPendingForSync(profile); | 121 SyncExtensionHelper::GetInstance()->InstallExtensionsPendingForSync(profile); |
| 101 } | 122 } |
| 102 | 123 |
| 103 syncer::StringOrdinal GetPageOrdinalForApp(Profile* profile, | 124 syncer::StringOrdinal GetPageOrdinalForApp(Profile* profile, |
| 104 int app_index) { | 125 int app_index) { |
| 105 return SyncAppHelper::GetInstance()->GetPageOrdinalForApp( | 126 return SyncAppHelper::GetInstance()->GetPageOrdinalForApp( |
| 106 profile, CreateFakeAppName(app_index)); | 127 profile, CreateFakeAppName(app_index)); |
| 107 } | 128 } |
| 108 | 129 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 for (int i = 0; i < test()->num_clients(); ++i) { | 361 for (int i = 0; i < test()->num_clients(); ++i) { |
| 341 profiles.push_back(test()->GetProfile(i)); | 362 profiles.push_back(test()->GetProfile(i)); |
| 342 } | 363 } |
| 343 | 364 |
| 344 AppsMatchChecker checker(profiles); | 365 AppsMatchChecker checker(profiles); |
| 345 checker.Wait(); | 366 checker.Wait(); |
| 346 return !checker.TimedOut(); | 367 return !checker.TimedOut(); |
| 347 } | 368 } |
| 348 | 369 |
| 349 } // namespace apps_helper | 370 } // namespace apps_helper |
| OLD | NEW |