15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_APP_LIST_HELPER_H_ 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_APP_LIST_HELPER_H_ 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <string> 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/basictypes.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/memory/singleton.h" 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "sync/api/string_ordinal.h" 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class Profile; 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class SyncTest; 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace app_list { 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class AppListItem; 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class SyncAppListHelper { 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Singleton implementation. 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) static SyncAppListHelper* GetInstance(); 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Initializes the profiles in |test| and registers them with 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // internal data structures. 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void SetupIfNecessary(SyncTest* test); 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Returns true iff all existing profiles have the same app list entries 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // as the verifier. 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool AllProfilesHaveSameAppListAsVerifier(); 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Moves an app in |profile|. 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void MoveApp(Profile* profile, size_t from, size_t to); 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Moves an app in |profile| to |folder_id|. 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void MoveAppToFolder(Profile* profile, 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) size_t index, 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& folder_id); 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Moves an app in |profile| from |folder_id| to the top level list of apps. 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void MoveAppFromFolder(Profile* profile, 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) size_t index_in_folder, 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& folder_id); 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Copies ordinals for item matching |id| from |profile1| to test_->verifier. 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void CopyOrdinalsToVerifier(Profile* profile1, const std::string& id); 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Helper function for debugging, used to log the app lists on test failures. 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void PrintAppList(Profile* profile); 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) friend struct DefaultSingletonTraits<SyncAppListHelper>; 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SyncAppListHelper(); 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ~SyncAppListHelper(); 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Returns true iff |profile| has the same app list as |test_|->verifier() 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // and the app list entries all have the same state. 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool AppListMatchesVerifier(Profile* profile); 625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Helper function for debugging, logs info for an item, including the 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // contents of any folder items. 655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void PrintItem(Profile* profile, 665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) app_list::AppListItem* item, 675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const std::string& label); 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) SyncTest* test_; 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool setup_completed_; 715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(SyncAppListHelper); 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_APP_LIST_HELPER_H_ 76