OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/google/core/browser/google_url_tracker.h" | 5 #include "components/google/core/browser/google_url_tracker.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/prefs/pref_registry_simple.h" | 12 #include "base/prefs/pref_registry_simple.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "base/prefs/testing_pref_service.h" | 14 #include "base/prefs/testing_pref_service.h" |
15 #include "components/google/core/browser/google_pref_names.h" | 15 #include "components/google/core/browser/google_pref_names.h" |
16 #include "components/google/core/browser/google_url_tracker_client.h" | 16 #include "components/google/core/browser/google_url_tracker_client.h" |
17 #include "components/google/core/browser/google_url_tracker_infobar_delegate.h" | 17 #include "components/google/core/browser/google_url_tracker_infobar_delegate.h" |
18 #include "components/google/core/browser/google_url_tracker_navigation_helper.h" | 18 #include "components/google/core/browser/google_url_tracker_navigation_helper.h" |
19 #include "components/infobars/core/infobar.h" | 19 #include "components/infobars/core/infobar.h" |
20 #include "components/infobars/core/infobar_delegate.h" | 20 #include "components/infobars/core/infobar_delegate.h" |
| 21 #include "components/infobars/test/test_confirm_infobar_delegate_factory.h" |
21 #include "net/url_request/test_url_fetcher_factory.h" | 22 #include "net/url_request/test_url_fetcher_factory.h" |
22 #include "net/url_request/url_fetcher.h" | 23 #include "net/url_request/url_fetcher.h" |
23 #include "net/url_request/url_request_test_util.h" | 24 #include "net/url_request/url_request_test_util.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 // TestCallbackListener --------------------------------------------------- | 29 // TestCallbackListener --------------------------------------------------- |
29 | 30 |
30 class TestCallbackListener { | 31 class TestCallbackListener { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 infobars::InfoBarManager* infobar_manager); | 242 infobars::InfoBarManager* infobar_manager); |
242 void ExpectDefaultURLs() const; | 243 void ExpectDefaultURLs() const; |
243 void ExpectListeningForCommit(infobars::InfoBarManager* infobar_manager, | 244 void ExpectListeningForCommit(infobars::InfoBarManager* infobar_manager, |
244 bool listening); | 245 bool listening); |
245 bool listener_notified() const { return listener_.notified(); } | 246 bool listener_notified() const { return listener_.notified(); } |
246 void clear_listener_notified() { listener_.clear_notified(); } | 247 void clear_listener_notified() { listener_.clear_notified(); } |
247 | 248 |
248 private: | 249 private: |
249 base::MessageLoop message_loop_; | 250 base::MessageLoop message_loop_; |
250 TestingPrefServiceSimple prefs_; | 251 TestingPrefServiceSimple prefs_; |
| 252 TestConfirmInfoBarDelegateFactory confirm_info_bar_delegate_factory_; |
251 | 253 |
252 // Creating this allows us to call | 254 // Creating this allows us to call |
253 // net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests(). | 255 // net::NetworkChangeNotifier::NotifyObserversOfNetworkChangeForTests(). |
254 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 256 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
255 net::TestURLFetcherFactory fetcher_factory_; | 257 net::TestURLFetcherFactory fetcher_factory_; |
256 GoogleURLTrackerClient* client_; | 258 GoogleURLTrackerClient* client_; |
257 scoped_ptr<GoogleURLTracker> google_url_tracker_; | 259 scoped_ptr<GoogleURLTracker> google_url_tracker_; |
258 TestCallbackListener listener_; | 260 TestCallbackListener listener_; |
259 // This tracks the different "tabs" a test has "opened", so we can close them | 261 // This tracks the different "tabs" a test has "opened", so we can close them |
260 // properly before shutting down |google_url_tracker_|, which expects that. | 262 // properly before shutting down |google_url_tracker_|, which expects that. |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 EXPECT_FALSE(GetInfoBarDelegate(&infobar_manager) == NULL); | 1046 EXPECT_FALSE(GetInfoBarDelegate(&infobar_manager) == NULL); |
1045 GoogleURLTrackerInfoBarDelegate* delegate2 = | 1047 GoogleURLTrackerInfoBarDelegate* delegate2 = |
1046 GetInfoBarDelegate(&infobar_manager2); | 1048 GetInfoBarDelegate(&infobar_manager2); |
1047 ASSERT_FALSE(delegate2 == NULL); | 1049 ASSERT_FALSE(delegate2 == NULL); |
1048 SetNavigationPending(&infobar_manager, true); | 1050 SetNavigationPending(&infobar_manager, true); |
1049 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(&infobar_manager, true)); | 1051 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(&infobar_manager, true)); |
1050 delegate2->Close(false); | 1052 delegate2->Close(false); |
1051 SetNavigationPending(&infobar_manager, false); | 1053 SetNavigationPending(&infobar_manager, false); |
1052 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(&infobar_manager, false)); | 1054 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(&infobar_manager, false)); |
1053 } | 1055 } |
OLD | NEW |