Adds user settings/preferences page

Adds a home for viewing and editing user preferences at a new client
route: /settings/. This is first in a series of changes to bring
preferences editing to PolyGerrit. At this point the settings page is
read-only and mostly un-styled.

Introduces the gr-settings-view element which is added to gr-app in the
same manner as the other main PolyGerrit views. Introduces the /settings
route which will display the new view, or redirect to login if the user
is not authenticated. Adds a link to user settings in the
gr-account-dropdown.

Bug: Issue 3911
Change-Id: Ib164502d586518876737c6d333c8940f2898dad4
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.html b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.html
new file mode 100644
index 0000000..626d019
--- /dev/null
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.html
@@ -0,0 +1,83 @@
+<!DOCTYPE html>
+<!--
+Copyright (C) 2016 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
+<title>gr-settings-view</title>
+
+<script src="../../../bower_components/webcomponentsjs/webcomponents.min.js"></script>
+<script src="../../../bower_components/web-component-tester/browser.js"></script>
+
+<link rel="import" href="../../../bower_components/iron-test-helpers/iron-test-helpers.html">
+<link rel="import" href="gr-settings-view.html">
+
+<test-fixture id="basic">
+  <template>
+    <gr-settings-view></gr-settings-view>
+  </template>
+</test-fixture>
+
+<script>
+  suite('gr-settings-view tests', function() {
+    var element;
+    var account;
+    var preferences;
+
+    setup(function(done) {
+      account = {
+        _account_id: 123,
+        name: 'user name',
+        email: 'user@email',
+        username: 'user username',
+        registered: '2000-01-01 00:00:00.000000000',
+      };
+      preferences = {time_format: 'HHMM_12'};
+
+      stub('gr-rest-api-interface', {
+        getLoggedIn: function() { return Promise.resolve(true); },
+        getAccount: function() { return Promise.resolve(account); },
+        getPreferences: function() { return Promise.resolve(preferences); },
+      });
+      element = fixture('basic');
+
+      // Allow the element to render.
+      element.async(done, 1);
+    });
+
+    test('render', function() {
+      assert.isFalse(element._loading);
+
+      var sections = element.$$('fieldset').querySelectorAll('section');
+
+      function valueOf(title) {
+        var titleEl;
+        for (var i = 0; i < sections.length; i++) {
+          titleEl = sections[i].querySelector('.title');
+          if (titleEl.textContent === title) {
+            return sections[i].querySelector('.value').textContent;
+          }
+        }
+      }
+
+      assert.equal(valueOf('ID'), account._account_id);
+      assert.equal(valueOf('Name'), account.name);
+      assert.equal(valueOf('Email'), account.email);
+      assert.equal(valueOf('Username'), account.username);
+      assert.equal(element._computeRegistered(element.account.registered),
+          'Sat, 01 Jan 2000 00:00:00 GMT');
+    });
+  });
+</script>