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

Side by Side Diff: content/renderer/disambiguation_popup_helper_unittest.cc

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 "content/renderer/disambiguation_popup_helper.h" 5 #include "content/renderer/disambiguation_popup_helper.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/WebKit/public/platform/WebRect.h" 8 #include "third_party/WebKit/public/platform/WebRect.h"
9 #include "third_party/WebKit/public/platform/WebVector.h" 9 #include "third_party/WebKit/public/platform/WebVector.h"
10 #include "ui/gfx/rect.h" 10 #include "ui/gfx/rect.h"
(...skipping 15 matching lines...) Expand all
26 , kVisibleContentSize_(640, 480) 26 , kVisibleContentSize_(640, 480)
27 , kImplScale_(1) { } 27 , kImplScale_(1) { }
28 protected: 28 protected:
29 const gfx::Size kScreenSize_; 29 const gfx::Size kScreenSize_;
30 const gfx::Size kVisibleContentSize_; 30 const gfx::Size kVisibleContentSize_;
31 const float kImplScale_; 31 const float kImplScale_;
32 }; 32 };
33 33
34 TEST_F(DisambiguationPopupHelperUnittest, ClipByViewport) { 34 TEST_F(DisambiguationPopupHelperUnittest, ClipByViewport) {
35 gfx::Rect tap_rect(1000, 1000, 10, 10); 35 gfx::Rect tap_rect(1000, 1000, 10, 10);
36 WebKit::WebVector<WebKit::WebRect> target_rects(static_cast<size_t>(1)); 36 blink::WebVector<blink::WebRect> target_rects(static_cast<size_t>(1));
37 target_rects[0] = gfx::Rect(-20, -20, 10, 10); 37 target_rects[0] = gfx::Rect(-20, -20, 10, 10);
38 38
39 gfx::Rect zoom_rect; 39 gfx::Rect zoom_rect;
40 float scale = DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( 40 float scale = DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor(
41 tap_rect, target_rects, kScreenSize_, kVisibleContentSize_, kImplScale_, 41 tap_rect, target_rects, kScreenSize_, kVisibleContentSize_, kImplScale_,
42 &zoom_rect); 42 &zoom_rect);
43 43
44 EXPECT_TRUE(gfx::Rect(kVisibleContentSize_).Contains(zoom_rect)); 44 EXPECT_TRUE(gfx::Rect(kVisibleContentSize_).Contains(zoom_rect));
45 EXPECT_LE(kDisambiguationPopupMinScale, scale); 45 EXPECT_LE(kDisambiguationPopupMinScale, scale);
46 46
47 gfx::Size scaled_size = ToCeiledSize(ScaleSize(zoom_rect.size(), scale)); 47 gfx::Size scaled_size = ToCeiledSize(ScaleSize(zoom_rect.size(), scale));
48 EXPECT_TRUE(gfx::Rect(kScreenSize_).Contains(gfx::Rect(scaled_size))); 48 EXPECT_TRUE(gfx::Rect(kScreenSize_).Contains(gfx::Rect(scaled_size)));
49 } 49 }
50 50
51 TEST_F(DisambiguationPopupHelperUnittest, MiniTarget) { 51 TEST_F(DisambiguationPopupHelperUnittest, MiniTarget) {
52 gfx::Rect tap_rect(-5, -5, 20, 20); 52 gfx::Rect tap_rect(-5, -5, 20, 20);
53 WebKit::WebVector<WebKit::WebRect> target_rects(static_cast<size_t>(1)); 53 blink::WebVector<blink::WebRect> target_rects(static_cast<size_t>(1));
54 target_rects[0] = gfx::Rect(10, 10, 1, 1); 54 target_rects[0] = gfx::Rect(10, 10, 1, 1);
55 55
56 gfx::Rect zoom_rect; 56 gfx::Rect zoom_rect;
57 float scale = DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( 57 float scale = DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor(
58 tap_rect, target_rects, kScreenSize_, kVisibleContentSize_, kImplScale_, 58 tap_rect, target_rects, kScreenSize_, kVisibleContentSize_, kImplScale_,
59 &zoom_rect); 59 &zoom_rect);
60 60
61 EXPECT_TRUE(gfx::Rect(kVisibleContentSize_).Contains(zoom_rect)); 61 EXPECT_TRUE(gfx::Rect(kVisibleContentSize_).Contains(zoom_rect));
62 EXPECT_EQ(kDisambiguationPopupMaxScale, scale); 62 EXPECT_EQ(kDisambiguationPopupMaxScale, scale);
63 EXPECT_TRUE(zoom_rect.Contains(target_rects[0])); 63 EXPECT_TRUE(zoom_rect.Contains(target_rects[0]));
64 64
65 gfx::Size scaled_size = ToCeiledSize(ScaleSize(zoom_rect.size(), scale)); 65 gfx::Size scaled_size = ToCeiledSize(ScaleSize(zoom_rect.size(), scale));
66 EXPECT_TRUE(gfx::Rect(kScreenSize_).Contains(gfx::Rect(scaled_size))); 66 EXPECT_TRUE(gfx::Rect(kScreenSize_).Contains(gfx::Rect(scaled_size)));
67 } 67 }
68 68
69 TEST_F(DisambiguationPopupHelperUnittest, LongLinks) { 69 TEST_F(DisambiguationPopupHelperUnittest, LongLinks) {
70 gfx::Rect tap_rect(10, 10, 20, 20); 70 gfx::Rect tap_rect(10, 10, 20, 20);
71 WebKit::WebVector<WebKit::WebRect> target_rects(static_cast<size_t>(2)); 71 blink::WebVector<blink::WebRect> target_rects(static_cast<size_t>(2));
72 target_rects[0] = gfx::Rect(15, 15, 1000, 5); 72 target_rects[0] = gfx::Rect(15, 15, 1000, 5);
73 target_rects[1] = gfx::Rect(15, 25, 1000, 5); 73 target_rects[1] = gfx::Rect(15, 25, 1000, 5);
74 74
75 gfx::Rect zoom_rect; 75 gfx::Rect zoom_rect;
76 float scale = DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( 76 float scale = DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor(
77 tap_rect, target_rects, kScreenSize_, kVisibleContentSize_, kImplScale_, 77 tap_rect, target_rects, kScreenSize_, kVisibleContentSize_, kImplScale_,
78 &zoom_rect); 78 &zoom_rect);
79 79
80 EXPECT_TRUE(gfx::Rect(kVisibleContentSize_).Contains(zoom_rect)); 80 EXPECT_TRUE(gfx::Rect(kVisibleContentSize_).Contains(zoom_rect));
81 EXPECT_EQ(kDisambiguationPopupMaxScale, scale); 81 EXPECT_EQ(kDisambiguationPopupMaxScale, scale);
82 EXPECT_TRUE(zoom_rect.Contains(tap_rect)); 82 EXPECT_TRUE(zoom_rect.Contains(tap_rect));
83 83
84 gfx::Size scaled_size = ToCeiledSize(ScaleSize(zoom_rect.size(), scale)); 84 gfx::Size scaled_size = ToCeiledSize(ScaleSize(zoom_rect.size(), scale));
85 EXPECT_TRUE(gfx::Rect(kScreenSize_).Contains(gfx::Rect(scaled_size))); 85 EXPECT_TRUE(gfx::Rect(kScreenSize_).Contains(gfx::Rect(scaled_size)));
86 } 86 }
87 87
88 } // namespace content 88 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/disambiguation_popup_helper.cc ('k') | content/renderer/dom_serializer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698