OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "public/web/WebViewClient.h" | 51 #include "public/web/WebViewClient.h" |
52 #include "web/tests/FrameTestHelpers.h" | 52 #include "web/tests/FrameTestHelpers.h" |
53 #include <gmock/gmock.h> | 53 #include <gmock/gmock.h> |
54 #include <gtest/gtest.h> | 54 #include <gtest/gtest.h> |
55 | 55 |
56 #include <vector> | 56 #include <vector> |
57 | 57 |
58 namespace { | 58 namespace { |
59 | 59 |
60 using blink::FrameTestHelpers::runPendingTasks; | 60 using blink::FrameTestHelpers::runPendingTasks; |
| 61 using blink::FrameTestHelpers::UseMockScrollbarSettings; |
61 using namespace blink; | 62 using namespace blink; |
62 | 63 |
63 class ViewportTest : public testing::Test { | 64 class ViewportTest : public testing::Test { |
64 protected: | 65 protected: |
65 ViewportTest() | 66 ViewportTest() |
66 : m_baseURL("http://www.test.com/") | 67 : m_baseURL("http://www.test.com/") |
67 , m_chromeURL("chrome://") | 68 , m_chromeURL("chrome://") |
68 { | 69 { |
69 } | 70 } |
70 | 71 |
(...skipping 15 matching lines...) Expand all Loading... |
86 void executeScript(WebFrame* frame, const WebString& code) | 87 void executeScript(WebFrame* frame, const WebString& code) |
87 { | 88 { |
88 frame->executeScript(WebScriptSource(code)); | 89 frame->executeScript(WebScriptSource(code)); |
89 runPendingTasks(); | 90 runPendingTasks(); |
90 } | 91 } |
91 | 92 |
92 std::string m_baseURL; | 93 std::string m_baseURL; |
93 std::string m_chromeURL; | 94 std::string m_chromeURL; |
94 }; | 95 }; |
95 | 96 |
96 class UseMockScrollbarSettings { | |
97 public: | |
98 UseMockScrollbarSettings() | |
99 { | |
100 Settings::setMockScrollbarsEnabled(true); | |
101 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); | |
102 EXPECT_TRUE(ScrollbarTheme::theme()->usesOverlayScrollbars()); | |
103 } | |
104 | |
105 ~UseMockScrollbarSettings() | |
106 { | |
107 Settings::setMockScrollbarsEnabled(false); | |
108 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); | |
109 } | |
110 }; | |
111 | |
112 static void setViewportSettings(WebSettings* settings) | 97 static void setViewportSettings(WebSettings* settings) |
113 { | 98 { |
114 settings->setViewportEnabled(true); | 99 settings->setViewportEnabled(true); |
115 settings->setViewportMetaEnabled(true); | 100 settings->setViewportMetaEnabled(true); |
116 settings->setMainFrameResizesAreOrientationChanges(true); | 101 settings->setMainFrameResizesAreOrientationChanges(true); |
117 } | 102 } |
118 | 103 |
119 static PageScaleConstraints runViewportTest(Page* page, int initialWidth, int in
itialHeight) | 104 static PageScaleConstraints runViewportTest(Page* page, int initialWidth, int in
itialHeight) |
120 { | 105 { |
121 IntSize initialViewportSize(initialWidth, initialHeight); | 106 IntSize initialViewportSize(initialWidth, initialHeight); |
(...skipping 3043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3165 FrameTestHelpers::WebViewHelper webViewHelper; | 3150 FrameTestHelpers::WebViewHelper webViewHelper; |
3166 webViewHelper.initializeAndLoad(m_baseURL + "viewport/viewport-warnings-7.ht
ml", true, &webFrameClient, 0, setViewportSettings); | 3151 webViewHelper.initializeAndLoad(m_baseURL + "viewport/viewport-warnings-7.ht
ml", true, &webFrameClient, 0, setViewportSettings); |
3167 | 3152 |
3168 Page* page = webViewHelper.webViewImpl()->page(); | 3153 Page* page = webViewHelper.webViewImpl()->page(); |
3169 runViewportTest(page, 320, 352); | 3154 runViewportTest(page, 320, 352); |
3170 | 3155 |
3171 EXPECT_EQ(0U, webFrameClient.messages.size()); | 3156 EXPECT_EQ(0U, webFrameClient.messages.size()); |
3172 } | 3157 } |
3173 | 3158 |
3174 } // namespace | 3159 } // namespace |
OLD | NEW |