chromium/chrome/browser/ui/commerce/commerce_ui_tab_helper_unittest.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <memory>
#include <vector>

#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "chrome/browser/ui/commerce/commerce_ui_tab_helper.h"
#include "chrome/browser/ui/views/side_panel/side_panel_entry.h"
#include "chrome/browser/ui/views/side_panel/side_panel_registry.h"
#include "chrome/browser/ui/views/side_panel/side_panel_util.h"
#include "chrome/test/base/testing_profile.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/test/test_bookmark_client.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/commerce/core/mock_shopping_service.h"
#include "components/commerce/core/price_tracking_utils.h"
#include "components/commerce/core/shopping_service.h"
#include "components/commerce/core/subscriptions/commerce_subscription.h"
#include "components/commerce/core/test_utils.h"
#include "components/image_fetcher/core/mock_image_fetcher.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_web_contents_factory.h"
#include "content/public/test/web_contents_tester.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
#include "url/gurl.h"

namespace commerce {

namespace {

const char kProductUrl[] =;
const char kProductImageUrl[] =;
const uint64_t kClusterId =;
const char kProductClusterTitle[] =;

// Build a ProductInfo with the specified cluster ID, image URL and cluster
// title.
//   * If the image URL is not specified, it is left empty in the info object.
//   * If the cluster_title is not specified, it is left empty in the info
//   object.
std::optional<ProductInfo> CreateProductInfo(
    uint64_t cluster_id,
    const GURL& url = GURL(),
    const std::string cluster_title = std::string()) {}

}  // namespace

Shopping_ShoppingInformation;

class CommerceUiTabHelperTest : public testing::Test {};

// The price tracking icon shouldn't be available if no image URL was provided
// by the shopping service.
TEST_F(CommerceUiTabHelperTest,
       TestPriceTrackingIconAvailabilityIfNoImage) {}

// The price tracking state should not update in the helper if there is no image
// returbed by the shopping service.
TEST_F(CommerceUiTabHelperTest,
       TestPriceTrackingIconAvailabilityWithImage) {}

// Make sure unsubscribe without a bookmark for the current page is functional.
TEST_F(CommerceUiTabHelperTest, TestSubscriptionChangeNoBookmark) {}

TEST_F(CommerceUiTabHelperTest, TestShoppingInsightsSidePanelAvailable) {}

TEST_F(CommerceUiTabHelperTest, TestShoppingInsightsSidePanelUnavailable) {}

TEST_F(CommerceUiTabHelperTest,
       TestPriceInsightsIconNotAvailableIfEmptyProductInfo) {}

TEST_F(CommerceUiTabHelperTest,
       TestPriceInsightsIconNotAvailableIfNoProductClusterTitle) {}

TEST_F(CommerceUiTabHelperTest, TestRecordShoppingInformationUKM) {}

}  // namespace commerce