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

Side by Side Diff: chrome/test/live_sync/performance/extensions_sync_perf_test.cc

Issue 7828055: Move sync test code out of chrome/test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
(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 "base/stringprintf.h"
6 #include "chrome/browser/sync/profile_sync_service_harness.h"
7 #include "chrome/test/live_sync/extensions_helper.h"
8 #include "chrome/test/live_sync/live_sync_test.h"
9 #include "chrome/test/live_sync/performance/sync_timing_helper.h"
10
11 using extensions_helper::AllProfilesHaveSameExtensions;
12 using extensions_helper::AllProfilesHaveSameExtensionsAsVerifier;
13 using extensions_helper::DisableExtension;
14 using extensions_helper::EnableExtension;
15 using extensions_helper::GetInstalledExtensions;
16 using extensions_helper::InstallExtension;
17 using extensions_helper::InstallExtensionsPendingForSync;
18 using extensions_helper::IsExtensionEnabled;
19 using extensions_helper::UninstallExtension;
20
21 // TODO(braffert): Replicate these tests for apps.
22
23 static const int kNumExtensions = 150;
24
25 class ExtensionsSyncPerfTest : public LiveSyncTest {
26 public:
27 ExtensionsSyncPerfTest()
28 : LiveSyncTest(TWO_CLIENT),
29 extension_number_(0) {}
30
31 // Adds |num_extensions| new unique extensions to |profile|.
32 void AddExtensions(int profile, int num_extensions);
33
34 // Updates the enabled/disabled state for all extensions in |profile|.
35 void UpdateExtensions(int profile);
36
37 // Uninstalls all currently installed extensions from |profile|.
38 void RemoveExtensions(int profile);
39
40 // Returns the number of currently installed extensions for |profile|.
41 int GetExtensionCount(int profile);
42
43 private:
44 int extension_number_;
45 DISALLOW_COPY_AND_ASSIGN(ExtensionsSyncPerfTest);
46 };
47
48 void ExtensionsSyncPerfTest::AddExtensions(int profile, int num_extensions) {
49 for (int i = 0; i < num_extensions; ++i) {
50 InstallExtension(GetProfile(profile), extension_number_++);
51 }
52 }
53
54 void ExtensionsSyncPerfTest::UpdateExtensions(int profile) {
55 std::vector<int> extensions = GetInstalledExtensions(GetProfile(profile));
56 for (std::vector<int>::iterator it = extensions.begin();
57 it != extensions.end(); ++it) {
58 if (IsExtensionEnabled(GetProfile(profile), *it)) {
59 DisableExtension(GetProfile(profile), *it);
60 } else {
61 EnableExtension(GetProfile(profile), *it);
62 }
63 }
64 }
65
66 int ExtensionsSyncPerfTest::GetExtensionCount(int profile) {
67 return GetInstalledExtensions(GetProfile(profile)).size();
68 }
69
70 void ExtensionsSyncPerfTest::RemoveExtensions(int profile) {
71 std::vector<int> extensions = GetInstalledExtensions(GetProfile(profile));
72 for (std::vector<int>::iterator it = extensions.begin();
73 it != extensions.end(); ++it) {
74 UninstallExtension(GetProfile(profile), *it);
75 }
76 }
77
78 IN_PROC_BROWSER_TEST_F(ExtensionsSyncPerfTest, P0) {
79 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
80 int num_default_extensions = GetExtensionCount(0);
81 int expected_extension_count = num_default_extensions + kNumExtensions;
82
83 // TCM ID - 7563874.
84 AddExtensions(0, kNumExtensions);
85 base::TimeDelta dt =
86 SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
87 InstallExtensionsPendingForSync(GetProfile(1));
88 ASSERT_EQ(expected_extension_count, GetExtensionCount(1));
89 SyncTimingHelper::PrintResult("extensions", "add_extensions", dt);
90
91 // TCM ID - 7655397.
92 UpdateExtensions(0);
93 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
94 ASSERT_EQ(expected_extension_count, GetExtensionCount(1));
95 SyncTimingHelper::PrintResult("extensions", "update_extensions", dt);
96
97 // TCM ID - 7567721.
98 RemoveExtensions(0);
99 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
100 ASSERT_EQ(num_default_extensions, GetExtensionCount(1));
101 SyncTimingHelper::PrintResult("extensions", "delete_extensions", dt);
102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698