| OLD | NEW |
| 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 "chrome/browser/rlz/chrome_rlz_tracker_delegate.h" | 5 #include "chrome/browser/rlz/chrome_rlz_tracker_delegate.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/test/scoped_task_environment.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "content/public/browser/navigation_details.h" | 11 #include "content/public/browser/navigation_details.h" |
| 11 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
| 12 #include "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
| 13 #include "content/public/browser/notification_source.h" | 14 #include "content/public/browser/notification_source.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 using content::NavigationEntry; | 17 using content::NavigationEntry; |
| 17 using content::LoadCommittedDetails; | 18 using content::LoadCommittedDetails; |
| 18 | 19 |
| 19 class ChromeRLZTrackerDelegateTest : public testing::Test { | 20 class ChromeRLZTrackerDelegateTest : public testing::Test { |
| 20 public: | 21 public: |
| 21 ChromeRLZTrackerDelegateTest() : delegate_(new ChromeRLZTrackerDelegate) {} | 22 ChromeRLZTrackerDelegateTest() : delegate_(new ChromeRLZTrackerDelegate) {} |
| 22 ~ChromeRLZTrackerDelegateTest() override {} | 23 ~ChromeRLZTrackerDelegateTest() override {} |
| 23 | 24 |
| 24 void SendNotification(int type, | 25 void SendNotification(int type, |
| 25 const content::NotificationSource& source, | 26 const content::NotificationSource& source, |
| 26 const content::NotificationDetails& details) { | 27 const content::NotificationDetails& details) { |
| 27 content::NotificationObserver* observer = delegate_.get(); | 28 content::NotificationObserver* observer = delegate_.get(); |
| 28 observer->Observe(type, source, details); | 29 observer->Observe(type, source, details); |
| 29 } | 30 } |
| 30 | 31 |
| 31 private: | 32 private: |
| 33 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 32 std::unique_ptr<ChromeRLZTrackerDelegate> delegate_; | 34 std::unique_ptr<ChromeRLZTrackerDelegate> delegate_; |
| 33 }; | 35 }; |
| 34 | 36 |
| 35 TEST_F(ChromeRLZTrackerDelegateTest, ObserveHandlesBadArgs) { | 37 TEST_F(ChromeRLZTrackerDelegateTest, ObserveHandlesBadArgs) { |
| 36 std::unique_ptr<content::LoadCommittedDetails> details( | 38 std::unique_ptr<content::LoadCommittedDetails> details( |
| 37 new content::LoadCommittedDetails()); | 39 new content::LoadCommittedDetails()); |
| 38 std::unique_ptr<content::NavigationEntry> entry( | 40 std::unique_ptr<content::NavigationEntry> entry( |
| 39 content::NavigationEntry::Create()); | 41 content::NavigationEntry::Create()); |
| 40 details->entry = entry.get(); | 42 details->entry = entry.get(); |
| 41 details->entry->SetTransitionType(ui::PAGE_TRANSITION_LINK); | 43 details->entry->SetTransitionType(ui::PAGE_TRANSITION_LINK); |
| 42 SendNotification(content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 44 SendNotification(content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 43 content::NotificationService::AllSources(), | 45 content::NotificationService::AllSources(), |
| 44 content::Details<NavigationEntry>(nullptr)); | 46 content::Details<NavigationEntry>(nullptr)); |
| 45 SendNotification(content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 47 SendNotification(content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 46 content::NotificationService::AllSources(), | 48 content::NotificationService::AllSources(), |
| 47 content::Details<LoadCommittedDetails>(details.get())); | 49 content::Details<LoadCommittedDetails>(details.get())); |
| 48 } | 50 } |
| OLD | NEW |