sync_app_list_helper.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
1// Copyright 2013 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#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_APP_LIST_HELPER_H_ 6#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_APP_LIST_HELPER_H_ 7 8#include <string> 9 10#include "base/basictypes.h" 11#include "base/memory/singleton.h" 12#include "sync/api/string_ordinal.h" 13 14class Profile; 15class SyncTest; 16 17namespace app_list { 18class AppListItem; 19} 20 21class SyncAppListHelper { 22 public: 23 // Singleton implementation. 24 static SyncAppListHelper* GetInstance(); 25 26 // Initializes the profiles in |test| and registers them with 27 // internal data structures. 28 void SetupIfNecessary(SyncTest* test); 29 30 // Returns true iff all existing profiles have the same app list entries 31 // as the verifier. 32 bool AllProfilesHaveSameAppListAsVerifier(); 33 34 // Moves an app in |profile|. 35 void MoveApp(Profile* profile, size_t from, size_t to); 36 37 // Moves an app in |profile| to |folder_id|. 38 void MoveAppToFolder(Profile* profile, 39 size_t index, 40 const std::string& folder_id); 41 42 // Moves an app in |profile| from |folder_id| to the top level list of apps. 43 void MoveAppFromFolder(Profile* profile, 44 size_t index_in_folder, 45 const std::string& folder_id); 46 47 // Copies ordinals for item matching |id| from |profile1| to test_->verifier. 48 void CopyOrdinalsToVerifier(Profile* profile1, const std::string& id); 49 50 // Helper function for debugging, used to log the app lists on test failures. 51 void PrintAppList(Profile* profile); 52 53 private: 54 friend struct DefaultSingletonTraits<SyncAppListHelper>; 55 56 SyncAppListHelper(); 57 ~SyncAppListHelper(); 58 59 // Returns true iff |profile| has the same app list as |test_|->verifier() 60 // and the app list entries all have the same state. 61 bool AppListMatchesVerifier(Profile* profile); 62 63 // Helper function for debugging, logs info for an item, including the 64 // contents of any folder items. 65 void PrintItem(Profile* profile, 66 app_list::AppListItem* item, 67 const std::string& label); 68 69 SyncTest* test_; 70 bool setup_completed_; 71 72 DISALLOW_COPY_AND_ASSIGN(SyncAppListHelper); 73}; 74 75#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_APP_LIST_HELPER_H_ 76