blob: ba0a0bc9004088814fcb6482be3badbd75728597 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/font.h"
namespace gfx {
TEST(CanvasTest, StringWidth) {
const string16 text = UTF8ToUTF16("Test");
const int width = Canvas::GetStringWidth(text, Font());
EXPECT_GT(width, 0);
}
TEST(CanvasTest, StringWidthEmptyString) {
const string16 text = UTF8ToUTF16("");
const int width = Canvas::GetStringWidth(text, Font());
EXPECT_EQ(0, width);
}
TEST(CanvasTest, StringSizeEmptyString) {
const Font font;
const string16 text = UTF8ToUTF16("");
int width = 0;
int height = 0;
Canvas::SizeStringInt(text, font, &width, &height, 0);
EXPECT_EQ(0, width);
EXPECT_GT(height, 0);
}
} // namespace gfx
|