Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: chrome/test/android/javatests_staging/src/org/chromium/chrome/test/omaha/MockRequestGenerator.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.test.omaha;
6
7 import android.content.Context;
8 import android.text.TextUtils;
9
10 import org.chromium.chrome.browser.omaha.RequestGenerator;
11 import org.xmlpull.v1.XmlSerializer;
12
13 import java.io.IOException;
14
15 /** Mocks out the RequestGenerator for tests. */
16 public class MockRequestGenerator extends RequestGenerator {
17 public enum DeviceType {
18 HANDSET, TABLET
19 }
20
21 public static final String UUID_PHONE = "uuid_phone";
22 public static final String UUID_TABLET = "uuid_tablet";
23 public static final String APP_ATTRIBUTE_1 = "app_attribute_1";
24 public static final String APP_ATTRIBUTE_2 = "app_attribute_2";
25 public static final String APP_VALUE_1 = "app_value_1";
26 public static final String APP_VALUE_2 = "app_value_2";
27 public static final String REQUEST_ATTRIBUTE_1 = "request_attribute_1";
28 public static final String REQUEST_ATTRIBUTE_2 = "request_attribute_2";
29 public static final String REQUEST_VALUE_1 = "request_value_1";
30 public static final String REQUEST_VALUE_2 = "request_value_2";
31 public static final String SERVER_URL = "http://totallylegitserver.com";
32
33 private static final String BRAND = "MOCK";
34 private static final String CLIENT = "mock-client";
35 private static final String LANGUAGE = "zz-ZZ";
36 private static final String ADDITIONAL_PARAMETERS = "chromium; manufacturer; model";
37
38 private final boolean mIsOnTablet;
39
40 public MockRequestGenerator(Context context, DeviceType deviceType) {
41 super(context);
42 mIsOnTablet = deviceType == DeviceType.TABLET;
43 }
44
45 @Override
46 public String getAppId() {
47 return mIsOnTablet ? UUID_TABLET : UUID_PHONE;
48 }
49
50 @Override
51 public String getBrand() {
52 return BRAND;
53 }
54
55 @Override
56 public String getClient() {
57 return CLIENT;
58 }
59
60 @Override
61 public String getLanguage() {
62 return LANGUAGE;
63 }
64
65 @Override
66 public String getAdditionalParameters() {
67 return ADDITIONAL_PARAMETERS;
68 }
69
70 @Override
71 public String getServerUrl() {
72 return SERVER_URL;
73 }
74
75 @Override
76 protected void appendExtraAttributes(String tag, XmlSerializer serializer) t hrows IOException {
77 if (TextUtils.equals(tag, "app")) {
78 serializer.attribute(null, APP_ATTRIBUTE_1, APP_VALUE_1);
79 serializer.attribute(null, APP_ATTRIBUTE_2, APP_VALUE_2);
80 } else if (TextUtils.equals(tag, "request")) {
81 serializer.attribute(null, REQUEST_ATTRIBUTE_1, REQUEST_VALUE_1);
82 serializer.attribute(null, REQUEST_ATTRIBUTE_2, REQUEST_VALUE_2);
83 }
84 }
85
86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698