This source file includes following definitions.
- TEST
#include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(OmniboxPopupModelTest, ComputeMatchMaxWidths) {
int contents_max_width, description_max_width;
const int separator_width = 10;
const int kMinimumContentsWidth = 300;
int contents_width, description_width, available_width;
contents_width = 100;
description_width = 50;
available_width = 200;
OmniboxPopupModel::ComputeMatchMaxWidths(
contents_width, separator_width, description_width, available_width,
true, &contents_max_width, &description_max_width);
EXPECT_EQ(contents_width, contents_max_width);
EXPECT_EQ(description_width, description_max_width);
contents_width = 100;
description_width = 50;
available_width = 100;
OmniboxPopupModel::ComputeMatchMaxWidths(
contents_width, separator_width, description_width, available_width,
true, &contents_max_width, &description_max_width);
EXPECT_EQ(contents_width, contents_max_width);
EXPECT_EQ(0, description_max_width);
contents_width = 300;
description_width = 100;
available_width = 384;
OmniboxPopupModel::ComputeMatchMaxWidths(
contents_width, separator_width, description_width, available_width,
true, &contents_max_width, &description_max_width);
EXPECT_EQ(contents_width, contents_max_width);
EXPECT_EQ(0, description_max_width);
contents_width = 310;
description_width = 150;
available_width = 400;
OmniboxPopupModel::ComputeMatchMaxWidths(
contents_width, separator_width, description_width, available_width,
true, &contents_max_width, &description_max_width);
OmniboxPopupModel::ComputeMatchMaxWidths(
310, separator_width, 150, 400, true, &contents_max_width,
&description_max_width);
EXPECT_EQ(kMinimumContentsWidth, contents_max_width);
EXPECT_EQ(available_width - kMinimumContentsWidth - separator_width,
description_max_width);
contents_width = 400;
description_width = 0;
available_width = 200;
OmniboxPopupModel::ComputeMatchMaxWidths(
contents_width, separator_width, description_width, available_width,
true, &contents_max_width, &description_max_width);
EXPECT_EQ(contents_width, contents_max_width);
EXPECT_EQ(0, description_max_width);
contents_width = 395;
description_width = 395;
available_width = 700;
OmniboxPopupModel::ComputeMatchMaxWidths(
contents_width, separator_width, description_width, available_width,
true, &contents_max_width, &description_max_width);
EXPECT_EQ(345, contents_max_width);
EXPECT_EQ(345, description_max_width);
contents_width = 395;
description_width = 395;
available_width = 700;
OmniboxPopupModel::ComputeMatchMaxWidths(
contents_width, separator_width, description_width, available_width,
false, &contents_max_width, &description_max_width);
EXPECT_EQ(contents_width, contents_max_width);
EXPECT_EQ((available_width - contents_width - separator_width),
description_max_width);
contents_width = 395;
description_width = 395;
available_width = 699;
OmniboxPopupModel::ComputeMatchMaxWidths(
contents_width, separator_width, description_width, available_width,
true, &contents_max_width, &description_max_width);
EXPECT_EQ(345, contents_max_width);
EXPECT_EQ(344, description_max_width);
contents_width = 1;
description_width = 1;
available_width = 0;
OmniboxPopupModel::ComputeMatchMaxWidths(
contents_width, separator_width, description_width, available_width,
true, &contents_max_width, &description_max_width);
EXPECT_EQ(0, contents_max_width);
EXPECT_EQ(0, description_max_width);
}