[go: nahoru, domu]

blob: d163ba311e868dde7ac32ecb8690ca3e195f4a98 [file] [log] [blame]
Avi Drissman8ce0344d2022-09-13 20:40:561// Copyright 2021 The Chromium Authors
Jiaming Cheng58b378b32021-07-02 18:47:182// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "google_apis/calendar/calendar_api_url_generator.h"
6
Gabriel Charetted87f10f2022-03-31 00:44:227#include "base/time/time.h"
Jiaming Cheng58b378b32021-07-02 18:47:188#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
9
10namespace google_apis {
11
12namespace calendar {
13
14// Make sure the hard-coded urls are returned.
15TEST(CalendarApiUrlGeneratorTest, GetColorListUrl) {
16 CalendarApiUrlGenerator url_generator_;
17 EXPECT_EQ("https://www.googleapis.com/calendar/v3/colors",
18 url_generator_.GetCalendarColorListUrl().spec());
19}
20
21TEST(CalendarApiUrlGeneratorTest, GetEventListUrl) {
22 CalendarApiUrlGenerator url_generator_;
23 base::Time start;
24 EXPECT_TRUE(base::Time::FromString("13 Jun 2021 10:00 PST", &start));
25 base::Time end;
26 EXPECT_TRUE(base::Time::FromString("16 Jun 2021 10:00 PST", &end));
27 EXPECT_EQ(
28 "https://www.googleapis.com/calendar/v3/calendars/primary/"
29 "events?timeMin=2021-06-13T18%3A00%3A00.000Z"
Roger Tinkoff73d4ae42021-10-24 19:37:4630 "&timeMax=2021-06-16T18%3A00%3A00.000Z"
Artsiom Mitrokhinc9535da2022-05-02 18:17:1531 "&singleEvents=true"
Artsiom Mitrokhin1c8f9bf2022-09-06 20:54:0732 "&maxAttendees=1"
33 "&maxResults=123",
Artsiom Mitrokhinc9535da2022-05-02 18:17:1534 url_generator_
35 .GetCalendarEventListUrl(start, end, /*single_events=*/true,
Artsiom Mitrokhin1c8f9bf2022-09-06 20:54:0736 /*max_attendees=*/1,
37 /*max_results=*/123)
Artsiom Mitrokhinc9535da2022-05-02 18:17:1538 .spec());
39}
40
Artsiom Mitrokhin1c8f9bf2022-09-06 20:54:0741TEST(CalendarApiUrlGeneratorTest,
42 GetEventListUrlWithDefaultOptionalParameters) {
Artsiom Mitrokhinc9535da2022-05-02 18:17:1543 CalendarApiUrlGenerator url_generator_;
44 base::Time start;
45 EXPECT_TRUE(base::Time::FromString("13 Jun 2021 10:00 PST", &start));
46 base::Time end;
47 EXPECT_TRUE(base::Time::FromString("16 Jun 2021 10:00 PST", &end));
48 EXPECT_EQ(
49 "https://www.googleapis.com/calendar/v3/calendars/primary/"
50 "events?timeMin=2021-06-13T18%3A00%3A00.000Z"
51 "&timeMax=2021-06-16T18%3A00%3A00.000Z"
Roger Tinkoff73d4ae42021-10-24 19:37:4652 "&singleEvents=true",
Artsiom Mitrokhinc9535da2022-05-02 18:17:1553 url_generator_
54 .GetCalendarEventListUrl(start, end, /*single_events=*/true,
Artsiom Mitrokhin1c8f9bf2022-09-06 20:54:0755 /*max_attendees=*/absl::nullopt,
56 /*max_results=*/absl::nullopt)
Roger Tinkoff73d4ae42021-10-24 19:37:4657 .spec());
Jiaming Cheng58b378b32021-07-02 18:47:1858}
59
60} // namespace calendar
61} // namespace google_apis