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

Side by Side Diff: Source/web/tests/RenderTableCellTest.cpp

Issue 23506013: Make the embedder responsible for creating the WebFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add WebViewHelper for unittests. Created 7 years, 3 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 25 matching lines...) Expand all
36 36
37 #include <gtest/gtest.h> 37 #include <gtest/gtest.h>
38 38
39 using namespace WebKit; 39 using namespace WebKit;
40 40
41 namespace WebCore { 41 namespace WebCore {
42 42
43 namespace { 43 namespace {
44 44
45 class RenderTableCellDeathTest : public testing::Test { 45 class RenderTableCellDeathTest : public testing::Test {
46 // It's unfortunate that we have to get the whole browser stack to test one RenderObject 46 protected:
47 // but the code needs it. 47 static void SetUpTestCase() {
48 static Frame* frame() 48 // It's unfortunate that we have to get the whole browser stack to test one RenderObject
49 { 49 // but the code needs it.
50 static WebView* webView; 50 s_webViewHelper = new FrameTestHelpers::WebViewHelper();
51 s_webViewHelper->initializeAndLoad("about:blank");
52 s_webViewHelper->webView()->setFocus(true);
53 }
51 54
52 if (webView) 55 static void TearDownTestCase() {
53 return toWebFrameImpl(webView->mainFrame())->frame(); 56 delete s_webViewHelper;
54
55 webView = FrameTestHelpers::createWebViewAndLoad("about:blank");
56 webView->setFocus(true);
57 return toWebFrameImpl(webView->mainFrame())->frame();
58 } 57 }
59 58
60 static Document* document() 59 static Document* document()
61 { 60 {
62 return frame()->document(); 61 return toWebFrameImpl(s_webViewHelper->webView()->mainFrame())->frame()- >document();
63 } 62 }
64 63
65 virtual void SetUp() 64 virtual void SetUp()
66 { 65 {
67 m_cell = RenderTableCell::createAnonymous(document()); 66 m_cell = RenderTableCell::createAnonymous(document());
68 } 67 }
69 68
70 virtual void TearDown() 69 virtual void TearDown()
71 { 70 {
72 m_cell->destroy(); 71 m_cell->destroy();
73 } 72 }
74 73
75 protected:
76 RenderTableCell* m_cell; 74 RenderTableCell* m_cell;
75
76 private:
77 static FrameTestHelpers::WebViewHelper* s_webViewHelper;
77 }; 78 };
78 79
80 FrameTestHelpers::WebViewHelper* RenderTableCellDeathTest::s_webViewHelper = 0;
81
79 TEST_F(RenderTableCellDeathTest, CanSetColumn) 82 TEST_F(RenderTableCellDeathTest, CanSetColumn)
80 { 83 {
81 static const unsigned columnIndex = 10; 84 static const unsigned columnIndex = 10;
82 m_cell->setCol(columnIndex); 85 m_cell->setCol(columnIndex);
83 EXPECT_EQ(columnIndex, m_cell->col()); 86 EXPECT_EQ(columnIndex, m_cell->col());
84 } 87 }
85 88
86 TEST_F(RenderTableCellDeathTest, CanSetColumnToMaxColumnIndex) 89 TEST_F(RenderTableCellDeathTest, CanSetColumnToMaxColumnIndex)
87 { 90 {
88 m_cell->setCol(maxColumnIndex); 91 m_cell->setCol(maxColumnIndex);
(...skipping 12 matching lines...) Expand all
101 TEST_F(RenderTableCellDeathTest, CrashIfSettingUnsetColumnIndex) 104 TEST_F(RenderTableCellDeathTest, CrashIfSettingUnsetColumnIndex)
102 { 105 {
103 ASSERT_DEATH(m_cell->setCol(unsetColumnIndex), ""); 106 ASSERT_DEATH(m_cell->setCol(unsetColumnIndex), "");
104 } 107 }
105 108
106 #endif 109 #endif
107 110
108 } 111 }
109 112
110 } // namespace WebCore 113 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698