15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_APPS_HELPER_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_APPS_HELPER_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/sync/test/integration/sync_test.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "sync/api/string_ordinal.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Profile;
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace apps_helper {
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Returns true iff the profile with index |index| has the same apps (hosted,
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// legacy packaged and platform) as the verifier.
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool HasSameAppsAsVerifier(int index) WARN_UNUSED_RESULT;
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Returns true iff all existing profiles have the same apps (hosted,
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// legacy packaged and platform) as the verifier.
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool AllProfilesHaveSameAppsAsVerifier() WARN_UNUSED_RESULT;
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Installs the app for the given index to |profile|, and returns the extension
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ID of the new app.
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::string InstallApp(Profile* profile, int index);
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Installs the platform app for the given index to |profile|, and returns the
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// extension ID of the new app. Indices passed to this method should be distinct
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// from indices passed to InstallApp.
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)std::string InstallPlatformApp(Profile* profile, int index);
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Installs the app for the given index to all profiles (including the
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// verifier), and returns the extension ID of the new app.
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::string InstallAppForAllProfiles(int index);
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Uninstalls the app for the given index from |profile|. Assumes that it was
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// previously installed.
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void UninstallApp(Profile* profile, int index);
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Installs all pending synced apps for |profile|.
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InstallAppsPendingForSync(Profile* profile);
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
45f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// Enables the app for the given index on |profile|.
46f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)void EnableApp(Profile* profile, int index);
47f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
48f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// Disables the app for the given index on |profile|.
49f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)void DisableApp(Profile* profile, int index);
50f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Enables the app for the given index in incognito mode on |profile|.
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void IncognitoEnableApp(Profile* profile, int index);
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Disables the app for the given index in incognito mode on |profile|.
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void IncognitoDisableApp(Profile* profile, int index);
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Gets the page ordinal value for the application at the given index on
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// |profile|.
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)syncer::StringOrdinal GetPageOrdinalForApp(Profile* profile, int app_index);
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Sets a new |page_ordinal| value for the application at the given index
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// on |profile|.
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void SetPageOrdinalForApp(
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Profile* profile, int app_index,
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const syncer::StringOrdinal& page_ordinal);
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Gets the app launch ordinal value for the application at the given index on
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// |profile|.
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)syncer::StringOrdinal GetAppLaunchOrdinalForApp(
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Profile* profile, int app_index);
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Sets a new |page_ordinal| value for the application at the given index
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// on |profile|.
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void SetAppLaunchOrdinalForApp(
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    Profile* profile, int app_index,
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    const syncer::StringOrdinal& app_launch_ordinal);
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copy the page and app launch ordinal value for the application at the given
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// index on |profile_source| to |profile_destination|.
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The main intention of this is to properly setup the values on the verifier
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// profile in situations where the other profiles have conflicting values.
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void CopyNTPOrdinals(Profile* source, Profile* destination, int index);
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Fix any NTP icon collisions that are currently in |profile|.
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void FixNTPOrdinalCollisions(Profile* profile);
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
875f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Waits until all profiles have the same set of apps as the verifier.
885f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)//
895f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Returns false on time out.
905f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)bool AwaitAllProfilesHaveSameAppsAsVerifier();
915f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace apps_helper
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_SYNC_TEST_INTEGRATION_APPS_HELPER_H_
95