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