Chromium Code Reviews| Index: chrome/browser/rlz/chrome_rlz_tracker_delegate_unittest.cc |
| diff --git a/chrome/browser/rlz/chrome_rlz_tracker_delegate_unittest.cc b/chrome/browser/rlz/chrome_rlz_tracker_delegate_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fd7d6e00a24e0a619a3aeb8ab7497b5391410411 |
| --- /dev/null |
| +++ b/chrome/browser/rlz/chrome_rlz_tracker_delegate_unittest.cc |
| @@ -0,0 +1,48 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/rlz/chrome_rlz_tracker_delegate.h" |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "chrome/browser/chrome_notification_types.h" |
| +#include "content/public/browser/navigation_details.h" |
| +#include "content/public/browser/navigation_entry.h" |
| +#include "content/public/browser/notification_service.h" |
| +#include "content/public/browser/notification_source.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +using content::NavigationEntry; |
| +using content::LoadCommittedDetails; |
| + |
| +class ChromeRLZTrackerDelegateTest : public testing::Test { |
|
Roger Tawa OOO till Jul 10th
2015/07/02 18:22:28
I'm surprised this test case does not need to deri
sdefresne
2015/07/03 16:16:37
It was required to send / receive notifications. S
|
| + public: |
| + ChromeRLZTrackerDelegateTest() : delegate_(new ChromeRLZTrackerDelegate) {} |
| + ~ChromeRLZTrackerDelegateTest() override {} |
| + |
| + void SendNotification(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) { |
| + content::NotificationObserver* observer = delegate_.get(); |
| + observer->Observe(type, source, details); |
| + } |
| + |
| + private: |
| + scoped_ptr<ChromeRLZTrackerDelegate> delegate_; |
| +}; |
| + |
| +TEST_F(ChromeRLZTrackerDelegateTest, ObserveHandlesBadArgs) { |
| + scoped_ptr<content::LoadCommittedDetails> details( |
| + new content::LoadCommittedDetails()); |
| + scoped_ptr<content::NavigationEntry> entry( |
| + content::NavigationEntry::Create()); |
| + details->entry = entry.get(); |
| + details->entry->SetPageID(0); |
| + details->entry->SetTransitionType(ui::PAGE_TRANSITION_LINK); |
| + SendNotification(content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| + content::NotificationService::AllSources(), |
| + content::Details<NavigationEntry>(nullptr)); |
| + SendNotification(content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| + content::NotificationService::AllSources(), |
| + content::Details<LoadCommittedDetails>(details.get())); |
| +} |