Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: chrome/browser/autocomplete/extension_app_provider_unittest.cc

Issue 271393003: Use ExtensionRegistryObserver instead of deprecated extension notification from autocomplete (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: colon to period Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/autocomplete/autocomplete_match.h" 8 #include "chrome/browser/autocomplete/autocomplete_match.h"
9 #include "chrome/browser/autocomplete/extension_app_provider.h" 9 #include "chrome/browser/autocomplete/extension_app_provider.h"
10 #include "chrome/browser/history/history_service.h" 10 #include "chrome/browser/history/history_service.h"
11 #include "chrome/browser/history/history_service_factory.h" 11 #include "chrome/browser/history/history_service_factory.h"
12 #include "chrome/browser/history/url_database.h" 12 #include "chrome/browser/history/url_database.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using base::ASCIIToUTF16; 17 using base::ASCIIToUTF16;
18 18
19 class ExtensionAppProviderTest : public testing::Test { 19 class ExtensionAppProviderTest : public testing::Test {
20 protected: 20 protected:
21 struct test_data { 21 struct test_data {
22 const base::string16 input; 22 const base::string16 input;
23 const size_t num_results; 23 const size_t num_results;
24 const GURL output[3]; 24 const GURL output[3];
25 }; 25 };
26 26
27 ExtensionAppProviderTest() 27 ExtensionAppProviderTest()
28 : ui_thread_(content::BrowserThread::UI, &message_loop_), 28 : ui_thread_(content::BrowserThread::UI, &message_loop_),
29 history_service_(NULL) { } 29 profile_(new TestingProfile),
30 app_provider_(new ExtensionAppProvider(NULL, profile_.get())),
31 history_service_(NULL) {}
30 virtual ~ExtensionAppProviderTest() { } 32 virtual ~ExtensionAppProviderTest() { }
31 33
32 virtual void SetUp() OVERRIDE; 34 virtual void SetUp() OVERRIDE;
33 35
34 void RunTest(test_data* keyword_cases, 36 void RunTest(test_data* keyword_cases,
35 int num_cases); 37 int num_cases);
36 38
37 protected: 39 protected:
38 base::MessageLoopForUI message_loop_; 40 base::MessageLoopForUI message_loop_;
39 content::TestBrowserThread ui_thread_; 41 content::TestBrowserThread ui_thread_;
42 scoped_ptr<TestingProfile> profile_;
40 scoped_refptr<ExtensionAppProvider> app_provider_; 43 scoped_refptr<ExtensionAppProvider> app_provider_;
41 scoped_ptr<TestingProfile> profile_;
42 HistoryService* history_service_; 44 HistoryService* history_service_;
43 }; 45 };
44 46
45 void ExtensionAppProviderTest::SetUp() { 47 void ExtensionAppProviderTest::SetUp() {
46 profile_.reset(new TestingProfile());
47 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); 48 ASSERT_TRUE(profile_->CreateHistoryService(true, false));
48 profile_->BlockUntilHistoryProcessesPendingRequests(); 49 profile_->BlockUntilHistoryProcessesPendingRequests();
49 history_service_ = 50 history_service_ =
50 HistoryServiceFactory::GetForProfile(profile_.get(), 51 HistoryServiceFactory::GetForProfile(profile_.get(),
51 Profile::EXPLICIT_ACCESS); 52 Profile::EXPLICIT_ACCESS);
52 53
53 app_provider_ = new ExtensionAppProvider(NULL, profile_.get());
54
55 struct TestExtensionApp { 54 struct TestExtensionApp {
56 const char* app_name; 55 const char* app_name;
57 const char* launch_url; 56 const char* launch_url;
58 bool should_match_against_launch_url; 57 bool should_match_against_launch_url;
59 const char* title; 58 const char* title;
60 int typed_count; 59 int typed_count;
61 } kExtensionApps[] = { 60 } kExtensionApps[] = {
62 {"COYB", "http://asdf/", true, "COYB", 7}, 61 {"COYB", "http://asdf/", true, "COYB", 7},
63 {"NSNO", "http://fdsa/", true, "NSNO", 2}, 62 {"NSNO", "http://fdsa/", true, "NSNO", 2},
64 {"APPP", "chrome-extension://xyz/", false, "APPP", 2}, 63 {"APPP", "chrome-extension://xyz/", false, "APPP", 2},
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ExtensionAppProvider::ExtensionApp extension_app = 147 ExtensionAppProvider::ExtensionApp extension_app =
149 {ASCIIToUTF16(cases[i].name), url, true}; 148 {ASCIIToUTF16(cases[i].name), url, true};
150 AutocompleteMatch match = 149 AutocompleteMatch match =
151 app_provider_->CreateAutocompleteMatch(input, 150 app_provider_->CreateAutocompleteMatch(input,
152 extension_app, 151 extension_app,
153 0, 152 0,
154 base::string16::npos); 153 base::string16::npos);
155 EXPECT_EQ(ASCIIToUTF16(cases[i].match_contents), match.contents); 154 EXPECT_EQ(ASCIIToUTF16(cases[i].match_contents), match.contents);
156 } 155 }
157 } 156 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/extension_app_provider.cc ('k') | chrome/browser/autocomplete/shortcuts_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698