// Copyright 2015 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <stdint.h> #include "base/strings/string_number_conversions.h" #include "content/browser/notifications/notification_id_generator.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" #include "url/origin.h" namespace content { namespace { const int64_t kPersistentNotificationId = …; const char kExampleTag[] = …; class NotificationIdGeneratorTest : public ::testing::Test { … }; // ----------------------------------------------------------------------------- // Persistent notifications // Two calls to the generator with exactly the same information should result // in exactly the same notification ids being generated. TEST_F(NotificationIdGeneratorTest, GenerateForPersistent_IsDetermenistic) { … } // The origin of the notification will impact the generated notification id. TEST_F(NotificationIdGeneratorTest, GenerateForPersistent_DifferentOrigins) { … } // The tag, when non-empty, will impact the generated notification id. TEST_F(NotificationIdGeneratorTest, GenerateForPersistent_DifferentTags) { … } // The persistent or non-persistent notification id will impact the generated // notification id when the tag is empty. TEST_F(NotificationIdGeneratorTest, GenerateForPersistent_DifferentIds) { … } // Using a numeric tag that could resemble a persistent notification id should // not be equal to a notification without a tag, but with that id. TEST_F(NotificationIdGeneratorTest, GenerateForPersistent_NumericTagAmbiguity) { … } // Using port numbers and a tag which, when concatenated, could end up being // equal to each other if origins stop ending with slashes. TEST_F(NotificationIdGeneratorTest, GenerateForPersistent_OriginPortAmbiguity) { … } // ----------------------------------------------------------------------------- // Non-persistent notifications TEST_F(NotificationIdGeneratorTest, GenerateForNonPersistent_IsDeterministic) { … } TEST_F(NotificationIdGeneratorTest, GenerateForNonPersistent_DifferentOrigins) { … } TEST_F(NotificationIdGeneratorTest, GenerateForNonPersistent_DifferentTokens) { … } // Use port numbers and a token which, when concatenated, could end up being // equal to each other if origins stop ending with slashes. TEST_F(NotificationIdGeneratorTest, GenerateForNonPersistent_OriginPortAmbiguity) { … } // ----------------------------------------------------------------------------- // Both persistent and non-persistent notifications. // Verifies that the static Is(Non)PersistentNotification helpers can correctly // identify persistent and non-persistent notification IDs. TEST_F(NotificationIdGeneratorTest, DetectIdFormat) { … } TEST_F(NotificationIdGeneratorTest, ShownByBrowser) { … } } // namespace } // namespace content