Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: chrome/browser/renderer_host/web_cache_manager_browsertest.cc

Issue 11419276: Remove tabstrip wrappers in browser_tabstrip. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 5 #include <string>
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/process_util.h" 8 #include "base/process_util.h"
9 #include "chrome/browser/renderer_host/web_cache_manager.h" 9 #include "chrome/browser/renderer_host/web_cache_manager.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_commands.h" 11 #include "chrome/browser/ui/browser_commands.h"
12 #include "chrome/browser/ui/browser_tabstrip.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/public/browser/render_process_host.h" 15 #include "content/public/browser/render_process_host.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/result_codes.h" 17 #include "content/public/common/result_codes.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 using content::WebContents; 20 using content::WebContents;
21 21
22 class WebCacheManagerBrowserTest : public InProcessBrowserTest { 22 class WebCacheManagerBrowserTest : public InProcessBrowserTest {
23 }; 23 };
24 24
25 // Regression test for http://crbug.com/12362. If a renderer crashes and the 25 // Regression test for http://crbug.com/12362. If a renderer crashes and the
26 // user navigates to another tab and back, the browser doesn't crash. 26 // user navigates to another tab and back, the browser doesn't crash.
27 IN_PROC_BROWSER_TEST_F(WebCacheManagerBrowserTest, CrashOnceOnly) { 27 IN_PROC_BROWSER_TEST_F(WebCacheManagerBrowserTest, CrashOnceOnly) {
28 const FilePath kTestDir(FILE_PATH_LITERAL("google")); 28 const FilePath kTestDir(FILE_PATH_LITERAL("google"));
29 const FilePath kTestFile(FILE_PATH_LITERAL("google.html")); 29 const FilePath kTestFile(FILE_PATH_LITERAL("google.html"));
30 GURL url(ui_test_utils::GetTestUrl(kTestDir, kTestFile)); 30 GURL url(ui_test_utils::GetTestUrl(kTestDir, kTestFile));
31 31
32 ui_test_utils::NavigateToURL(browser(), url); 32 ui_test_utils::NavigateToURL(browser(), url);
33 33
34 chrome::NewTab(browser()); 34 chrome::NewTab(browser());
35 ui_test_utils::NavigateToURL(browser(), url); 35 ui_test_utils::NavigateToURL(browser(), url);
36 36
37 WebContents* tab = chrome::GetWebContentsAt(browser(), 0); 37 WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(0);
38 ASSERT_TRUE(tab != NULL); 38 ASSERT_TRUE(tab != NULL);
39 base::KillProcess(tab->GetRenderProcessHost()->GetHandle(), 39 base::KillProcess(tab->GetRenderProcessHost()->GetHandle(),
40 content::RESULT_CODE_KILLED, true); 40 content::RESULT_CODE_KILLED, true);
41 41
42 chrome::ActivateTabAt(browser(), 0, true); 42 browser()->tab_strip_model()->ActivateTabAt(0, true);
43 chrome::NewTab(browser()); 43 chrome::NewTab(browser());
44 ui_test_utils::NavigateToURL(browser(), url); 44 ui_test_utils::NavigateToURL(browser(), url);
45 45
46 chrome::ActivateTabAt(browser(), 0, true); 46 browser()->tab_strip_model()->ActivateTabAt(0, true);
47 chrome::NewTab(browser()); 47 chrome::NewTab(browser());
48 ui_test_utils::NavigateToURL(browser(), url); 48 ui_test_utils::NavigateToURL(browser(), url);
49 49
50 // We would have crashed at the above line with the bug. 50 // We would have crashed at the above line with the bug.
51 51
52 chrome::ActivateTabAt(browser(), 0, true); 52 browser()->tab_strip_model()->ActivateTabAt(0, true);
53 chrome::CloseTab(browser()); 53 chrome::CloseTab(browser());
54 chrome::ActivateTabAt(browser(), 0, true); 54 browser()->tab_strip_model()->ActivateTabAt(0, true);
55 chrome::CloseTab(browser()); 55 chrome::CloseTab(browser());
56 chrome::ActivateTabAt(browser(), 0, true); 56 browser()->tab_strip_model()->ActivateTabAt(0, true);
57 chrome::CloseTab(browser()); 57 chrome::CloseTab(browser());
58 58
59 ui_test_utils::NavigateToURL(browser(), url); 59 ui_test_utils::NavigateToURL(browser(), url);
60 60
61 EXPECT_EQ( 61 EXPECT_EQ(
62 WebCacheManager::GetInstance()->active_renderers_.size(), 1U); 62 WebCacheManager::GetInstance()->active_renderers_.size(), 1U);
63 EXPECT_EQ( 63 EXPECT_EQ(
64 WebCacheManager::GetInstance()->inactive_renderers_.size(), 0U); 64 WebCacheManager::GetInstance()->inactive_renderers_.size(), 0U);
65 EXPECT_EQ( 65 EXPECT_EQ(
66 WebCacheManager::GetInstance()->stats_.size(), 1U); 66 WebCacheManager::GetInstance()->stats_.size(), 1U);
67 } 67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698