OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/test/live_sync/live_apps_sync_test.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "base/string_number_conversions.h" | |
9 #include "chrome/browser/profiles/profile.h" | |
10 #include "chrome/common/extensions/extension.h" | |
11 | |
12 namespace { | |
13 | |
14 std::string CreateFakeAppName(int index) { | |
15 return "fakeapp" + base::IntToString(index); | |
16 } | |
17 | |
18 } // namespace | |
19 | |
20 LiveAppsSyncTest::LiveAppsSyncTest(TestType test_type) | |
21 : LiveSyncTest(test_type) {} | |
22 | |
23 LiveAppsSyncTest::~LiveAppsSyncTest() {} | |
24 | |
25 bool LiveAppsSyncTest::SetupClients() { | |
26 if (!LiveSyncTest::SetupClients()) | |
27 return false; | |
28 | |
29 extension_helper_.Setup(this); | |
30 return true; | |
31 } | |
32 | |
33 bool LiveAppsSyncTest::HasSameAppsAsVerifier(int index) { | |
34 // TODO(akalin): We may want to filter out non-apps for some tests. | |
35 return extension_helper_.ExtensionStatesMatch(GetProfile(index), verifier()); | |
36 } | |
37 | |
38 bool LiveAppsSyncTest::AllProfilesHaveSameAppsAsVerifier() { | |
39 for (int i = 0; i < num_clients(); ++i) { | |
40 if (!HasSameAppsAsVerifier(i)) { | |
41 LOG(ERROR) << "Profile " << i << " doesn't have the same apps as the" | |
42 " verifier profile."; | |
43 return false; | |
44 } | |
45 } | |
46 return true; | |
47 } | |
48 | |
49 void LiveAppsSyncTest::InstallApp(Profile* profile, int index) { | |
50 return extension_helper_.InstallExtension(profile, | |
51 CreateFakeAppName(index), | |
52 Extension::TYPE_HOSTED_APP); | |
53 } | |
54 | |
55 void LiveAppsSyncTest::UninstallApp(Profile* profile, int index) { | |
56 return extension_helper_.UninstallExtension(profile, | |
57 CreateFakeAppName(index)); | |
58 } | |
59 | |
60 void LiveAppsSyncTest::EnableApp(Profile* profile, int index) { | |
61 return extension_helper_.EnableExtension(profile, | |
62 CreateFakeAppName(index)); | |
63 } | |
64 | |
65 void LiveAppsSyncTest::DisableApp(Profile* profile, int index) { | |
66 return extension_helper_.DisableExtension(profile, | |
67 CreateFakeAppName(index)); | |
68 } | |
69 | |
70 void LiveAppsSyncTest::IncognitoEnableApp(Profile* profile, int index) { | |
71 return extension_helper_.IncognitoEnableExtension(profile, | |
72 CreateFakeAppName(index)); | |
73 } | |
74 | |
75 void LiveAppsSyncTest::IncognitoDisableApp(Profile* profile, int index) { | |
76 return extension_helper_.IncognitoDisableExtension(profile, | |
77 CreateFakeAppName(index)); | |
78 } | |
79 | |
80 void LiveAppsSyncTest::InstallAppsPendingForSync( | |
81 Profile* profile) { | |
82 extension_helper_.InstallExtensionsPendingForSync( | |
83 profile, Extension::TYPE_HOSTED_APP); | |
84 } | |
OLD | NEW |