• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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 <string>
6 
7 #include "chrome/browser/search/suggestions/proto/suggestions.pb.h"
8 #include "chrome/browser/search/suggestions/thumbnail_manager.h"
9 #include "chrome/test/base/testing_profile.h"
10 #include "content/public/test/test_browser_thread_bundle.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "url/gurl.h"
13 
14 namespace {
15 
16 const char kTestUrl[] = "http://go.com/";
17 const char kTestThumbnailUrl[] = "http://thumb.com/anchor_download_test.png";
18 
19 class ThumbnailManagerTest : public testing::Test {
20  protected:
21   content::TestBrowserThreadBundle thread_bundle_;
22 };
23 
24 }  // namespace
25 
26 namespace suggestions {
27 
TEST_F(ThumbnailManagerTest,InitializeThumbnailMapTest)28 TEST_F(ThumbnailManagerTest, InitializeThumbnailMapTest) {
29   SuggestionsProfile suggestions_profile;
30   ChromeSuggestion* suggestion = suggestions_profile.add_suggestions();
31   suggestion->set_url(kTestUrl);
32   suggestion->set_thumbnail(kTestThumbnailUrl);
33 
34   TestingProfile profile;
35   ThumbnailManager thumbnail_manager(&profile);
36   thumbnail_manager.InitializeThumbnailMap(suggestions_profile);
37 
38   GURL output;
39   EXPECT_TRUE(thumbnail_manager.GetThumbnailURL(GURL(kTestUrl), &output));
40   EXPECT_EQ(GURL(kTestThumbnailUrl), output);
41 
42   EXPECT_FALSE(thumbnail_manager.GetThumbnailURL(GURL("http://b.com"),
43                                                  &output));
44 }
45 
46 }  // namespace suggestions
47