fake_tile_service.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2020 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. #ifndef COMPONENTS_QUERY_TILES_TEST_FAKE_TILE_SERVICE_H_
  5. #define COMPONENTS_QUERY_TILES_TEST_FAKE_TILE_SERVICE_H_
  6. #include <memory>
  7. #include <string>
  8. #include "base/memory/weak_ptr.h"
  9. #include "components/query_tiles/tile_service.h"
  10. namespace query_tiles {
  11. // A fake TileService that can be used for tests.
  12. class FakeTileService : public TileService {
  13. public:
  14. FakeTileService();
  15. ~FakeTileService() override;
  16. // Disallow copy/assign.
  17. FakeTileService(const FakeTileService& other) = delete;
  18. FakeTileService& operator=(const FakeTileService& other) = delete;
  19. private:
  20. // TileService implementation.
  21. void GetQueryTiles(GetTilesCallback callback) override;
  22. void GetTile(const std::string& tile_id, TileCallback callback) override;
  23. void StartFetchForTiles(bool is_from_reduced_mode,
  24. BackgroundTaskFinishedCallback callback) override;
  25. void CancelTask() override;
  26. void PurgeDb() override;
  27. void SetServerUrl(const std::string& url) override;
  28. void OnTileClicked(const std::string& tile_id) override;
  29. void OnQuerySelected(const absl::optional<std::string>& parent_tile_id,
  30. const std::u16string& query_text) override;
  31. Logger* GetLogger() override;
  32. std::vector<std::unique_ptr<Tile>> tiles_;
  33. base::WeakPtrFactory<FakeTileService> weak_ptr_factory_{this};
  34. };
  35. } // namespace query_tiles
  36. #endif // COMPONENTS_QUERY_TILES_TEST_FAKE_TILE_SERVICE_H_