OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Tests common functionality used by the Chrome Extensions webNavigation API | 5 // Tests common functionality used by the Chrome Extensions webNavigation API |
6 // implementation. | 6 // implementation. |
7 | 7 |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/browser_thread.h" | 11 #include "chrome/browser/browser_thread.h" |
12 #include "chrome/browser/extensions/extension_webnavigation_api.h" | 12 #include "chrome/browser/extensions/extension_webnavigation_api.h" |
13 #include "chrome/browser/renderer_host/test/test_render_view_host.h" | 13 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
14 #include "chrome/browser/tab_contents/test_tab_contents.h" | 14 #include "chrome/browser/tab_contents/test_tab_contents.h" |
15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
16 #include "chrome/test/testing_profile.h" | 16 #include "chrome/test/testing_profile.h" |
17 | 17 |
| 18 |
18 class FrameNavigationStateTest : public RenderViewHostTestHarness { | 19 class FrameNavigationStateTest : public RenderViewHostTestHarness { |
19 }; | 20 }; |
20 | 21 |
21 // Test that a frame is correctly tracked, and removed once the tab contents | 22 // Test that a frame is correctly tracked, and removed once the tab contents |
22 // goes away. | 23 // goes away. |
23 TEST_F(FrameNavigationStateTest, TrackFrame) { | 24 TEST_F(FrameNavigationStateTest, TrackFrame) { |
24 FrameNavigationState navigation_state; | 25 FrameNavigationState navigation_state; |
25 const long long frame_id1 = 23; | 26 const long long frame_id1 = 23; |
26 const long long frame_id2 = 42; | 27 const long long frame_id2 = 42; |
27 const GURL url1("http://www.google.com/"); | 28 const GURL url1("http://www.google.com/"); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 navigation_state.TrackFrame( | 97 navigation_state.TrackFrame( |
97 frame_id2, GURL(chrome::kUnreachableWebDataURL), false, contents()); | 98 frame_id2, GURL(chrome::kUnreachableWebDataURL), false, contents()); |
98 EXPECT_TRUE(navigation_state.CanSendEvents(frame_id1)); | 99 EXPECT_TRUE(navigation_state.CanSendEvents(frame_id1)); |
99 EXPECT_FALSE(navigation_state.CanSendEvents(frame_id2)); | 100 EXPECT_FALSE(navigation_state.CanSendEvents(frame_id2)); |
100 | 101 |
101 // However, when the frame navigates again, it should send events again. | 102 // However, when the frame navigates again, it should send events again. |
102 navigation_state.TrackFrame(frame_id2, url, false, contents()); | 103 navigation_state.TrackFrame(frame_id2, url, false, contents()); |
103 EXPECT_TRUE(navigation_state.CanSendEvents(frame_id1)); | 104 EXPECT_TRUE(navigation_state.CanSendEvents(frame_id1)); |
104 EXPECT_TRUE(navigation_state.CanSendEvents(frame_id2)); | 105 EXPECT_TRUE(navigation_state.CanSendEvents(frame_id2)); |
105 } | 106 } |
OLD | NEW |